From: Paolo Bonzini <pbonzini@redhat.com>
To: Brijesh Singh <brijesh.singh@amd.com>,
x86@kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: "Thomas Gleixner" <tglx@linutronix.de>,
"Ingo Molnar" <mingo@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"Joerg Roedel" <joro@8bytes.org>, "Borislav Petkov" <bp@suse.de>,
"Tom Lendacky" <thomas.lendacky@amd.com>
Subject: Re: [Part2 PATCH v5 31/31] KVM: X86: Restart the guest when insn_len is zero and SEV is enabled
Date: Wed, 18 Oct 2017 11:31:43 +0200 [thread overview]
Message-ID: <1ed3d49b-5373-fd4c-bf81-32dc6e3206cb@redhat.com> (raw)
In-Reply-To: <e09869bc-ab5b-dd53-1d72-e103675418d1@redhat.com>
On 18/10/2017 11:26, Paolo Bonzini wrote:
> On 04/10/2017 15:17, Brijesh Singh wrote:
>> + /*
>> + * On AMD platforms, under certain conditions insn_len may be zero on #NPF.
>> + * This can happen if a guest gets a page-fault on data access but the HW
>> + * table walker is not able to read the instruction page (e.g instruction
>> + * page is not present in memory).
>> + *
>> + * Typically, when insn_len is zero, x86_emulate_instruction() walks the
>> + * guest page table and fetches the instruction bytes from guest memory.
>> + * When SEV is enabled, the guest memory is encrypted with guest-specific
>> + * key hence hypervisor will not able to fetch the instruction bytes.
>> + * In those cases we simply restart the guest.
>> + */
>> + if (unlikely(!insn_len) &&
>> + kvm_x86_ops->mem_enc_enabled &&
>> + kvm_x86_ops->mem_enc_enabled(vcpu))
>> + return 1;
>> +
>
> Is it needed to test mem_enc_enabled? Could it instead test for the
> availability of decode assists?
More precisely, you could test "unlikely(insn && !insn_len)" here and,
in svm.c, pass insn as
static_cpu_has(X86_FEATURE_DECODEASSISTS) ?
svm->vmcb->control.insn_bytes : 0
Paolo
next prev parent reply other threads:[~2017-10-18 9:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-04 13:17 [Part2 PATCH v5 30/31] KVM: SVM: Do not install #UD intercept when " Brijesh Singh
2017-10-04 13:17 ` [Part2 PATCH v5 31/31] KVM: X86: Restart the guest when insn_len is zero and " Brijesh Singh
2017-10-18 9:26 ` Paolo Bonzini
2017-10-18 9:31 ` Paolo Bonzini [this message]
2017-10-18 12:19 ` Brijesh Singh
2017-10-18 13:00 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1ed3d49b-5373-fd4c-bf81-32dc6e3206cb@redhat.com \
--to=pbonzini@redhat.com \
--cc=bp@suse.de \
--cc=brijesh.singh@amd.com \
--cc=hpa@zytor.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®