* [PATCH for-4.8 1/2] x86/vmx: Correct the long mode check in vmx_cpuid_intercept()
@ 2016-11-14 11:01 Andrew Cooper
2016-11-14 11:01 ` [PATCH for-4.8 2/2] x86/traps: Don't call hvm_hypervisor_cpuid_leaf() for PV guests Andrew Cooper
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Andrew Cooper @ 2016-11-14 11:01 UTC (permalink / raw)
To: Xen-devel; +Cc: Andrew Cooper, Kevin Tian, Wei Liu, Jun Nakajima, Jan Beulich
%cs.L may be set in a legacy mode segment, or clear in a compatibility mode
segment; it is not the correct way to check for long mode being active.
Both of these situations result in incorrect visibility of the SYSCALL feature
in CPUID, and by extension, incorrect behaviour in hvm_efer_valid().
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Jun Nakajima <jun.nakajima@intel.com>
CC: Kevin Tian <kevin.tian@intel.com>
---
xen/arch/x86/hvm/vmx/vmx.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 9a8f694..a18db28 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2407,7 +2407,6 @@ static void vmx_cpuid_intercept(
unsigned int *ecx, unsigned int *edx)
{
unsigned int input = *eax;
- struct segment_register cs;
struct vcpu *v = current;
hvm_cpuid(input, eax, ebx, ecx, edx);
@@ -2416,8 +2415,7 @@ static void vmx_cpuid_intercept(
{
case 0x80000001:
/* SYSCALL is visible iff running in long mode. */
- vmx_get_segment_register(v, x86_seg_cs, &cs);
- if ( cs.attr.fields.l )
+ if ( hvm_long_mode_enabled(v) )
*edx |= cpufeat_mask(X86_FEATURE_SYSCALL);
else
*edx &= ~(cpufeat_mask(X86_FEATURE_SYSCALL));
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH for-4.8 2/2] x86/traps: Don't call hvm_hypervisor_cpuid_leaf() for PV guests
2016-11-14 11:01 [PATCH for-4.8 1/2] x86/vmx: Correct the long mode check in vmx_cpuid_intercept() Andrew Cooper
@ 2016-11-14 11:01 ` Andrew Cooper
2016-11-14 11:38 ` Jan Beulich
2016-11-14 11:35 ` [PATCH for-4.8 1/2] x86/vmx: Correct the long mode check in vmx_cpuid_intercept() Jan Beulich
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Andrew Cooper @ 2016-11-14 11:01 UTC (permalink / raw)
To: Xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich
Luckily, hvm_hypervisor_cpuid_leaf() and vmx_hypervisor_cpuid_leaf() are safe
to execute in the context of a PV guest, but HVM-specific feature flags
shouldn't be visible to PV guests.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
---
xen/arch/x86/traps.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 14abb62..d56d76e 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -928,6 +928,11 @@ int cpuid_hypervisor_leaves( uint32_t idx, uint32_t sub_idx,
break;
case 4:
+ if ( !has_hvm_container_domain(currd) )
+ {
+ *eax = *ebx = *ecx = *edx = 0;
+ break;
+ }
hvm_hypervisor_cpuid_leaf(sub_idx, eax, ebx, ecx, edx);
break;
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH for-4.8 1/2] x86/vmx: Correct the long mode check in vmx_cpuid_intercept()
2016-11-14 11:01 [PATCH for-4.8 1/2] x86/vmx: Correct the long mode check in vmx_cpuid_intercept() Andrew Cooper
2016-11-14 11:01 ` [PATCH for-4.8 2/2] x86/traps: Don't call hvm_hypervisor_cpuid_leaf() for PV guests Andrew Cooper
@ 2016-11-14 11:35 ` Jan Beulich
2016-11-15 9:59 ` Wei Liu
2016-11-16 6:40 ` Tian, Kevin
3 siblings, 0 replies; 7+ messages in thread
From: Jan Beulich @ 2016-11-14 11:35 UTC (permalink / raw)
To: Andrew Cooper; +Cc: Kevin Tian, Wei Liu, Jun Nakajima, Xen-devel
>>> On 14.11.16 at 12:01, <andrew.cooper3@citrix.com> wrote:
> %cs.L may be set in a legacy mode segment, or clear in a compatibility mode
> segment; it is not the correct way to check for long mode being active.
>
> Both of these situations result in incorrect visibility of the SYSCALL feature
> in CPUID, and by extension, incorrect behaviour in hvm_efer_valid().
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH for-4.8 2/2] x86/traps: Don't call hvm_hypervisor_cpuid_leaf() for PV guests
2016-11-14 11:01 ` [PATCH for-4.8 2/2] x86/traps: Don't call hvm_hypervisor_cpuid_leaf() for PV guests Andrew Cooper
@ 2016-11-14 11:38 ` Jan Beulich
2016-11-14 13:18 ` Andrew Cooper
0 siblings, 1 reply; 7+ messages in thread
From: Jan Beulich @ 2016-11-14 11:38 UTC (permalink / raw)
To: Andrew Cooper; +Cc: Wei Liu, Xen-devel
>>> On 14.11.16 at 12:01, <andrew.cooper3@citrix.com> wrote:
> Luckily, hvm_hypervisor_cpuid_leaf() and vmx_hypervisor_cpuid_leaf() are safe
> to execute in the context of a PV guest, but HVM-specific feature flags
> shouldn't be visible to PV guests.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
albeit ...
> --- a/xen/arch/x86/traps.c
> +++ b/xen/arch/x86/traps.c
> @@ -928,6 +928,11 @@ int cpuid_hypervisor_leaves( uint32_t idx, uint32_t sub_idx,
> break;
>
> case 4:
> + if ( !has_hvm_container_domain(currd) )
> + {
> + *eax = *ebx = *ecx = *edx = 0;
> + break;
> + }
> hvm_hypervisor_cpuid_leaf(sub_idx, eax, ebx, ecx, edx);
> break;
... this being the last leaf, wouldn't we better limit the number of
leaves (reported in leaf 0) to 3 for PV?
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH for-4.8 2/2] x86/traps: Don't call hvm_hypervisor_cpuid_leaf() for PV guests
2016-11-14 11:38 ` Jan Beulich
@ 2016-11-14 13:18 ` Andrew Cooper
0 siblings, 0 replies; 7+ messages in thread
From: Andrew Cooper @ 2016-11-14 13:18 UTC (permalink / raw)
To: Jan Beulich; +Cc: Wei Liu, Xen-devel
On 14/11/16 11:38, Jan Beulich wrote:
>>>> On 14.11.16 at 12:01, <andrew.cooper3@citrix.com> wrote:
>> Luckily, hvm_hypervisor_cpuid_leaf() and vmx_hypervisor_cpuid_leaf() are safe
>> to execute in the context of a PV guest, but HVM-specific feature flags
>> shouldn't be visible to PV guests.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> albeit ...
>
>> --- a/xen/arch/x86/traps.c
>> +++ b/xen/arch/x86/traps.c
>> @@ -928,6 +928,11 @@ int cpuid_hypervisor_leaves( uint32_t idx, uint32_t sub_idx,
>> break;
>>
>> case 4:
>> + if ( !has_hvm_container_domain(currd) )
>> + {
>> + *eax = *ebx = *ecx = *edx = 0;
>> + break;
>> + }
>> hvm_hypervisor_cpuid_leaf(sub_idx, eax, ebx, ecx, edx);
>> break;
> ... this being the last leaf, wouldn't we better limit the number of
> leaves (reported in leaf 0) to 3 for PV?
I considered this, but decided not to.
The current max leaf handling is fragile, owing to some dubious control
from the toolstack, and the existence of XEN_CPUID_MAX_NUM_LEAVES in the
public API is absolutely broken.
I am going to need to rework this all anyway, and its not clear whether
we can/should report less than 4 leaves to PV guests.
~Andrew
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH for-4.8 1/2] x86/vmx: Correct the long mode check in vmx_cpuid_intercept()
2016-11-14 11:01 [PATCH for-4.8 1/2] x86/vmx: Correct the long mode check in vmx_cpuid_intercept() Andrew Cooper
2016-11-14 11:01 ` [PATCH for-4.8 2/2] x86/traps: Don't call hvm_hypervisor_cpuid_leaf() for PV guests Andrew Cooper
2016-11-14 11:35 ` [PATCH for-4.8 1/2] x86/vmx: Correct the long mode check in vmx_cpuid_intercept() Jan Beulich
@ 2016-11-15 9:59 ` Wei Liu
2016-11-16 6:40 ` Tian, Kevin
3 siblings, 0 replies; 7+ messages in thread
From: Wei Liu @ 2016-11-15 9:59 UTC (permalink / raw)
To: Andrew Cooper; +Cc: Kevin Tian, Wei Liu, Jun Nakajima, Jan Beulich, Xen-devel
On Mon, Nov 14, 2016 at 11:01:25AM +0000, Andrew Cooper wrote:
> %cs.L may be set in a legacy mode segment, or clear in a compatibility mode
> segment; it is not the correct way to check for long mode being active.
>
> Both of these situations result in incorrect visibility of the SYSCALL feature
> in CPUID, and by extension, incorrect behaviour in hvm_efer_valid().
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Both patches:
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH for-4.8 1/2] x86/vmx: Correct the long mode check in vmx_cpuid_intercept()
2016-11-14 11:01 [PATCH for-4.8 1/2] x86/vmx: Correct the long mode check in vmx_cpuid_intercept() Andrew Cooper
` (2 preceding siblings ...)
2016-11-15 9:59 ` Wei Liu
@ 2016-11-16 6:40 ` Tian, Kevin
3 siblings, 0 replies; 7+ messages in thread
From: Tian, Kevin @ 2016-11-16 6:40 UTC (permalink / raw)
To: Andrew Cooper, Xen-devel; +Cc: Wei Liu, Nakajima, Jun, Jan Beulich
> From: Andrew Cooper [mailto:andrew.cooper3@citrix.com]
> Sent: Monday, November 14, 2016 7:01 PM
>
> %cs.L may be set in a legacy mode segment, or clear in a compatibility mode
> segment; it is not the correct way to check for long mode being active.
>
> Both of these situations result in incorrect visibility of the SYSCALL feature
> in CPUID, and by extension, incorrect behaviour in hvm_efer_valid().
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-11-16 6:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-14 11:01 [PATCH for-4.8 1/2] x86/vmx: Correct the long mode check in vmx_cpuid_intercept() Andrew Cooper
2016-11-14 11:01 ` [PATCH for-4.8 2/2] x86/traps: Don't call hvm_hypervisor_cpuid_leaf() for PV guests Andrew Cooper
2016-11-14 11:38 ` Jan Beulich
2016-11-14 13:18 ` Andrew Cooper
2016-11-14 11:35 ` [PATCH for-4.8 1/2] x86/vmx: Correct the long mode check in vmx_cpuid_intercept() Jan Beulich
2016-11-15 9:59 ` Wei Liu
2016-11-16 6:40 ` Tian, Kevin
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).