Re: [PATCH v2 1/2] x86/spec: fix reporting of BHB clearing usage from guest entry points

2024-04-25 Thread Andrew Cooper
On 18/04/2024 4:52 pm, Roger Pau Monne wrote:
> Reporting whether the BHB clearing on entry is done for the different domains
> types based on cpu_has_bhb_seq is incorrect, as that variable signals whether

I'd prefer s/incorrect/unhelpful/ here.

As pointed out, it's currently like IBPB-entry in this regard,
identifying whether the block is in place; not whether it's used by the
condition.

> there's a BHB clearing sequence selected, but that alone doesn't imply that
> such sequence is used from the PV and/or HVM entry points.
>
> Instead use opt_bhb_entry_{pv,hvm} which do signal whether BHB clearing is
> performed on entry from PV/HVM.

I was going to ask for a note about dom0, but instead I need to make a
correction to the cmdline docs.  I'll do that in a separate patch.


> Fixes: 689ad48ce9cf ('x86/spec-ctrl: Wire up the Native-BHI software 
> sequences')
> Signed-off-by: Roger Pau Monné 

Reviewed-by: Andrew Cooper 

Can make the one tweak on commit.



Re: [PATCH v2 1/2] x86/spec: fix reporting of BHB clearing usage from guest entry points

2024-04-18 Thread Jan Beulich
On 18.04.2024 17:52, Roger Pau Monne wrote:
> Reporting whether the BHB clearing on entry is done for the different domains
> types based on cpu_has_bhb_seq is incorrect, as that variable signals whether
> there's a BHB clearing sequence selected, but that alone doesn't imply that
> such sequence is used from the PV and/or HVM entry points.
> 
> Instead use opt_bhb_entry_{pv,hvm} which do signal whether BHB clearing is
> performed on entry from PV/HVM.
> 
> Fixes: 689ad48ce9cf ('x86/spec-ctrl: Wire up the Native-BHI software 
> sequences')
> Signed-off-by: Roger Pau Monné 

This looks correct to me, so:
Reviewed-by: Jan Beulich 
But since Andrew indicated concerns, I won't mark it (locally) for being
ready to go in.

Jan



[PATCH v2 1/2] x86/spec: fix reporting of BHB clearing usage from guest entry points

2024-04-18 Thread Roger Pau Monne
Reporting whether the BHB clearing on entry is done for the different domains
types based on cpu_has_bhb_seq is incorrect, as that variable signals whether
there's a BHB clearing sequence selected, but that alone doesn't imply that
such sequence is used from the PV and/or HVM entry points.

Instead use opt_bhb_entry_{pv,hvm} which do signal whether BHB clearing is
performed on entry from PV/HVM.

Fixes: 689ad48ce9cf ('x86/spec-ctrl: Wire up the Native-BHI software sequences')
Signed-off-by: Roger Pau Monné 
---
Changes since v1:
 - Also fix usage of cpu_has_bhb_seq when deciding whether to print "None".
---
 xen/arch/x86/spec_ctrl.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index dd01e30844a1..1e831c1c108e 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -634,7 +634,7 @@ static void __init print_details(enum ind_thunk thunk)
(boot_cpu_has(X86_FEATURE_SC_MSR_HVM) ||
 boot_cpu_has(X86_FEATURE_SC_RSB_HVM) ||
 boot_cpu_has(X86_FEATURE_IBPB_ENTRY_HVM) ||
-cpu_has_bhb_seq || amd_virt_spec_ctrl ||
+opt_bhb_entry_hvm || amd_virt_spec_ctrl ||
 opt_eager_fpu || opt_verw_hvm)   ? ""   : " 
None",
boot_cpu_has(X86_FEATURE_SC_MSR_HVM)  ? " MSR_SPEC_CTRL" : "",
(boot_cpu_has(X86_FEATURE_SC_MSR_HVM) ||
@@ -643,7 +643,7 @@ static void __init print_details(enum ind_thunk thunk)
opt_eager_fpu ? " EAGER_FPU" : "",
opt_verw_hvm  ? " VERW"  : "",
boot_cpu_has(X86_FEATURE_IBPB_ENTRY_HVM)  ? " IBPB-entry": "",
-   cpu_has_bhb_seq   ? " BHB-entry" : "");
+   opt_bhb_entry_hvm ? " BHB-entry" : "");
 
 #endif
 #ifdef CONFIG_PV
@@ -651,14 +651,14 @@ static void __init print_details(enum ind_thunk thunk)
(boot_cpu_has(X86_FEATURE_SC_MSR_PV) ||
 boot_cpu_has(X86_FEATURE_SC_RSB_PV) ||
 boot_cpu_has(X86_FEATURE_IBPB_ENTRY_PV) ||
-cpu_has_bhb_seq ||
+opt_bhb_entry_pv ||
 opt_eager_fpu || opt_verw_pv)? ""   : " 
None",
boot_cpu_has(X86_FEATURE_SC_MSR_PV)   ? " MSR_SPEC_CTRL" : "",
boot_cpu_has(X86_FEATURE_SC_RSB_PV)   ? " RSB"   : "",
opt_eager_fpu ? " EAGER_FPU" : "",
opt_verw_pv   ? " VERW"  : "",
boot_cpu_has(X86_FEATURE_IBPB_ENTRY_PV)   ? " IBPB-entry": "",
-   cpu_has_bhb_seq   ? " BHB-entry" : "");
+   opt_bhb_entry_pv  ? " BHB-entry" : "");
 
 printk("  XPTI (64-bit PV only): Dom0 %s, DomU %s (with%s PCID)\n",
opt_xpti_hwdom ? "enabled" : "disabled",
-- 
2.44.0