From: Suravee Suthikulanit <suravee.suthikulpanit@amd.com>
To: "Egger, Christoph" <chegger@amazon.de>
Cc: Tim Deegan <tim@xen.org>, JBeulich@suse.com, xen-devel@lists.xen.org
Subject: Re: [PATCH 1/1 V4] x86/AMD: Fix nested svm crash due to assertion in __virt_to_maddr
Date: Wed, 31 Jul 2013 10:52:00 -0500 [thread overview]
Message-ID: <51F932A0.1030002@amd.com> (raw)
In-Reply-To: <51F775B8.6090601@amazon.de>
On 7/30/2013 3:13 AM, Egger, Christoph wrote:
> On 29.07.13 22:04, Tim Deegan wrote:
>> At 11:27 -0500 on 29 Jul (1375097276), Suravee Suthikulanit wrote:
>>> On 7/29/2013 5:43 AM, Tim Deegan wrote:
>>>> Hi,
>>>>
>>>> At 16:46 -0500 on 26 Jul (1374857167), suravee.suthikulpanit@amd.com wrote:
>>>>> From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
>>>>>
>>>>> Fix assertion in __virt_to_maddr when starting nested SVM guest
>>>>> in debug mode. Investigation has shown that svm_vmsave/svm_vmload
>>>>> make use of __pa() with invalid address.
>>>>>
>>>>> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
>>>> This looks much better, but I have a few comments still:
>>>>
>>>>> +static struct page_info *
>>>>> +_get_vmcb_page(struct domain *d, uint64_t vmcbaddr)
>>>> Can you give this a name that makes it clearer that it's for nested
>>>> VMCBs and not part of the handling of 'real' VMCBs? Also, please drop
>>>> the leading underscore.
>>> What about "get_nvmcb_page"?
>> Yes, that would be good.
>>
>>>>> + {
>>>>> + gdprintk(XENLOG_ERR,
>>>>> + "VMLOAD: mapping vmcb L1-GPA to MPA failed, injecting
>>>>> #UD\n");
>>>>> + ret = TRAP_invalid_op;
>>>> The documentation for VMLOAD suggests TRAP_gp_fault for this case.
>>> OK, I have also checked other exceptions injected in
>>> svm_vmexit_do_vmsave and svm_vm_exit_do_vmload, and the following should
>>> probably also changed to #GP as well.
>>>
>>> if (!nestedsvm_vmcb_map(v, vmcbaddr)) {
>>> gdprintk(XENLOG_ERR, "VMSAVE: mapping vmcb failed, injecting
>>> #UD\n");
>>> ret = TRAP_invalid_op;
>>> goto inject;
>>> }
>> Yes, that sounds right.
> Wait, documentation (http://support.amd.com/us/Processor_TechDocs/24593_APM_v2.pdf, page 470) says:
>
> VMLOAD and VMSAVE are available only at CPL-0 (#GP otherwise), and in protected mode with SVM enabled in EFER.SVME (#UD otherwise).
>
> Check the code path if EFER.SVME is guaranteed to be set. If not #UD
> is correct.
>
> Christoph
>
>
I also found more detail documented in the APM v3 (http://support.amd.com/us/Processor_TechDocs/24594_APM_v3.pdf).
// This instruction can only be executed in protected mode with SVM enabled
IF ((MSR_EFER.SVME == 0) || (!PROTECTED_MODE))
EXCEPTION [#UD]
// This instruction is only allowed at CPL 0
IF (CPL != 0)
EXCEPTION [#GP]
IF (rAX contains an unsupported system-physical address)
EXCEPTION [#GP]
In this case, in function "svm_vmexit_do_vmload" and "svm_vmexit_do_vmsave", the EFER.SVME should be enabled if nestedhvm_enabled(v->domain) is true.
I could also add the check to make sure that L1 guest enable the EFER.SVME (i.e. using the "hvm_svm_enabled(v)" macro).
Also, the nestedsvm_vmcb_map() is trying to access VMCB which from a given address. In this case, I also think it should be #GP when it fails.
Suravee
next prev parent reply other threads:[~2013-07-31 15:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-26 21:46 [PATCH 1/1 V4] x86/AMD: Fix nested svm crash due to assertion in __virt_to_maddr suravee.suthikulpanit
2013-07-29 10:43 ` Tim Deegan
2013-07-29 16:27 ` Suravee Suthikulanit
2013-07-29 20:04 ` Tim Deegan
2013-07-30 8:13 ` Egger, Christoph
2013-07-31 15:52 ` Suravee Suthikulanit [this message]
2013-07-30 8:05 ` Egger, Christoph
2013-07-31 8:46 ` Suravee Suthikulanit
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=51F932A0.1030002@amd.com \
--to=suravee.suthikulpanit@amd.com \
--cc=JBeulich@suse.com \
--cc=chegger@amazon.de \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.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;
as well as URLs for NNTP newsgroup(s).