i386: Remove ospke CPUID flag name
RFC PATCH 1/1 i386: Remove ospke CPUID flag name
RFC NOTE: Paolo, Richard, as far as I can see, there's no point in enabling OSPKE in user-mode QEMU. Do you confirm that?
OSPKE is not a static feature flag: it changes dynamically at runtime depending on CR4, and it was never configurable: KVM never returned OSPKE on GET_SUPPORTED_CPUID, and on TCG enables it automatically if CR4_PKE_MASK is set.
Remove OSPKE from the feature name array so users don't try to configure it manually.
--- target/i386/cpu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
target/i386/cpu.c +3 -2
@@ -564,7 +564,8 @@ static void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1,CPUID_7_0_EBX_HLE, CPUID_7_0_EBX_AVX2, CPUID_7_0_EBX_INVPCID, CPUID_7_0_EBX_RTM, CPUID_7_0_EBX_RDSEED */ -#define TCG_7_0_ECX_FEATURES (CPUID_7_0_ECX_PKU | CPUID_7_0_ECX_OSPKE | \ +#define TCG_7_0_ECX_FEATURES (CPUID_7_0_ECX_PKU | \ + /* CPUID_7_0_ECX_OSPKE is dynamic */ \CPUID_7_0_ECX_LA57 )#define TCG_7_0_EDX_FEATURES 0#define TCG_APM_FEATURES 0
@@ -781,7 +782,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = { [FEAT_7_0_ECX] = { .feat_names = {NULL ,"avx512vbmi" ,"umip" ,"pku" , -"ospke" ,NULL ,"avx512vbmi2" ,NULL , +NULL /* ospke */ ,NULL ,"avx512vbmi2" ,NULL ,"gfni" ,"vaes" ,"vpclmulqdq" ,"avx512vnni" ,"avx512bitalg" ,NULL ,"avx512-vpopcntdq" ,NULL , "la57", NULL, NULL, NULL,
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
Quoted 8 lines · Eduardo Habkost
RFC NOTE: Paolo, Richard, as far as I can see, there's no point in enabling OSPKE in user-mode QEMU. Do you confirm that?
OSPKE is not a static feature flag: it changes dynamically at runtime depending on CR4, and it was never configurable: KVM never returned OSPKE on
GET_SUPPORTED_CPUID, and on TCG enables it automatically ifCR4_PKE_MASKis set.
Quoted 7 lines
Remove OSPKE from the feature name array so users don't try to configure it manually.
Signed-off-by Eduardo Habkost <[email protected]>--- target/i386/cpu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
r~
Quoted 8 lines · Eduardo Habkost
RFC NOTE: Paolo, Richard, as far as I can see, there's no point in enabling OSPKE in user-mode QEMU. Do you confirm that?
OSPKE is not a static feature flag: it changes dynamically at runtime depending on CR4, and it was never configurable: KVM never returned OSPKE on
GET_SUPPORTED_CPUID, and on TCG enables it automatically ifCR4_PKE_MASKis set.
Quoted 4 lines
Remove OSPKE from the feature name array so users don't try to configure it manually.
Signed-off-by Eduardo Habkost <[email protected]>
Yes, it's the same as OSXSAVE. Thanks!
Paolo
Quoted 9 lines · Paolo Bonzini
Quoted 8 lines · Eduardo Habkost
RFC NOTE: Paolo, Richard, as far as I can see, there's no point in enabling OSPKE in user-mode QEMU. Do you confirm that?
OSPKE is not a static feature flag: it changes dynamically at runtime depending on CR4, and it was never configurable: KVM never returned OSPKE on
GET_SUPPORTED_CPUID, and on TCG enables it automatically ifCR4_PKE_MASKis set.
Quoted 6 lines
Quoted 4 lines
Remove OSPKE from the feature name array so users don't try to configure it manually.
Signed-off-by Eduardo Habkost <[email protected]>Yes, it's the same as OSXSAVE. Thanks!
CR4_OSXSAVE_MASK is automatically enabled on user-mode QEMU, though.
My question is if it would make any sense to enable CR4_PKE_MASK too.
Signature · 1 line
Eduardo
Quoted 11 lines · Eduardo Habkost
Quoted 6 lines
Quoted 5 lines
Remove OSPKE from the feature name array so users don't try to configure it manually.
Signed-off-by Eduardo Habkost <[email protected]>Yes, it's the same as OSXSAVE. Thanks!
CR4_OSXSAVE_MASKis automatically enabled on user-mode QEMU, though.My question is if it would make any sense to enable
CR4_PKE_MASKtoo.
If you mean OSPKE, then yes---if PKU is available. Likewise, OSXSAVE should only be enabled if XSAVE is available.
Paolo
Quoted 7 lines · Paolo Bonzini
Quoted 6 lines · Eduardo Habkost
Quoted 6 lines
Quoted 5 lines
Remove OSPKE from the feature name array so users don't try to configure it manually.
Signed-off-by Eduardo Habkost <[email protected]>Yes, it's the same as OSXSAVE. Thanks!
Quoted 8 lines
Quoted 5 lines
CR4_OSXSAVE_MASKis automatically enabled on user-mode QEMU, though.My question is if it would make any sense to enable
CR4_PKE_MASKtoo.If you mean OSPKE, then yes---if PKU is available. Likewise, OSXSAVE should only be enabled if XSAVE is available.
Yeah, I mean enabling it only if PKU is available, like we already do with OSXAVE/XSAVE.
But we don't do it today, so enabling it automatically in CONFIG_USER_ONLY would be a new feature. Would it be useful for anything, though?
I'm asking that to find out if somebody could be already using "-cpu ...,+ospke" with user-mode QEMU today (which this patch would break). If RDPKRU/WRPKRU is useless under user-mode QEMU, than we don't need to worry about that.
Signature · 1 line
Eduardo
Quoted 20 lines · Eduardo Habkost
Quoted 7 lines · Paolo Bonzini
Quoted 6 lines · Eduardo Habkost
Quoted 6 lines
Quoted 5 lines
Remove OSPKE from the feature name array so users don't try to configure it manually.
Signed-off-by Eduardo Habkost <[email protected]>Yes, it's the same as OSXSAVE. Thanks!
Quoted 8 lines
Quoted 5 lines
CR4_OSXSAVE_MASKis automatically enabled on user-mode QEMU, though.My question is if it would make any sense to enable
CR4_PKE_MASKtoo.If you mean OSPKE, then yes---if PKU is available. Likewise, OSXSAVE should only be enabled if XSAVE is available.
Yeah, I mean enabling it only if PKU is available, like we already do with OSXAVE/XSAVE.
Quoted 8 lines
But we don't do it today, so enabling it automatically in
CONFIG_USER_ONLYwould be a new feature. Would it be useful for anything, though?I'm asking that to find out if somebody could be already using "-cpu ...,+ospke" with user-mode QEMU today (which this patch would break). If RDPKRU/WRPKRU is useless under user-mode QEMU, than we don't need to worry about that.
Hmm, actually there are two more things to consider for user-mode emulation.
First, QEMU doesn't support any of pkey_mprotect, pkey_alloc, pkey_free, so it should probably never set OSPKE.
Second, for user-mode emulation it makes sense to allow flipping of OSPKE and OSXSAVE, because that corresponds to different behaviors of the underlying kernels. There have been bugs in fact with programs that incorrectly tested XSAVE instead of OSXSAVE, so it's worthwhile to let the user test both configurations.
So to sum up, the default for QEMU user-mode emulation should be OSXSAVE=XSAVE and OSPKE=0.
Paolo
Quoted 30 lines · Paolo Bonzini
Quoted 20 lines · Eduardo Habkost
Quoted 7 lines · Paolo Bonzini
Quoted 6 lines · Eduardo Habkost
Quoted 6 lines
Quoted 5 lines
Remove OSPKE from the feature name array so users don't try to configure it manually.
Signed-off-by Eduardo Habkost <[email protected]>Yes, it's the same as OSXSAVE. Thanks!
Quoted 8 lines
Quoted 5 lines
CR4_OSXSAVE_MASKis automatically enabled on user-mode QEMU, though.My question is if it would make any sense to enable
CR4_PKE_MASKtoo.If you mean OSPKE, then yes---if PKU is available. Likewise, OSXSAVE should only be enabled if XSAVE is available.
Yeah, I mean enabling it only if PKU is available, like we already do with OSXAVE/XSAVE.
Quoted 8 lines
But we don't do it today, so enabling it automatically in
CONFIG_USER_ONLYwould be a new feature. Would it be useful for anything, though?I'm asking that to find out if somebody could be already using "-cpu ...,+ospke" with user-mode QEMU today (which this patch would break). If RDPKRU/WRPKRU is useless under user-mode QEMU, than we don't need to worry about that.
Quoted 4 lines
Hmm, actually there are two more things to consider for user-mode emulation.
First, QEMU doesn't support any of
pkey_mprotect,pkey_alloc,pkey_free, so it should probably never set OSPKE.
This means "-cpu ...,+ospke" is useless today and we can safely remove support for it, right?
Quoted 5 lines
Second, for user-mode emulation it makes sense to allow flipping of OSPKE and OSXSAVE, because that corresponds to different behaviors of the underlying kernels. There have been bugs in fact with programs that incorrectly tested XSAVE instead of OSXSAVE, so it's worthwhile to let the user test both configurations.
However, "-cpu ...,-osxsave" has no effect today (user-mode QEMU unconditionally sets OSXSAVE), so that would be a new feature.
I assume this means I don't need to drop the osxsave patch from my queue, either.
Quoted 2 lines
So to sum up, the default for QEMU user-mode emulation should be OSXSAVE=XSAVE and OSPKE=0.
Thanks!
Signature · 1 line
Eduardo
Quoted 8 lines · Eduardo Habkost
Quoted 5 lines
Second, for user-mode emulation it makes sense to allow flipping of OSPKE and OSXSAVE, because that corresponds to different behaviors of the underlying kernels. There have been bugs in fact with programs that incorrectly tested XSAVE instead of OSXSAVE, so it's worthwhile to let the user test both configurations.
However, "-cpu ...,-osxsave" has no effect today (user-mode QEMU unconditionally sets OSXSAVE), so that would be a new feature.
Yes, understood.
Paolo
Quoted 6 lines
I assume this means I don't need to drop the osxsave patch from my queue, either.
Quoted 2 lines
So to sum up, the default for QEMU user-mode emulation should be OSXSAVE=XSAVE and OSPKE=0.
Thanks!