Thank you for your contribution! Sashiko AI review found 2 potential issue(s) 
to consider:
- [Medium] Uninitialized kernel stack memory is leaked to the hypervisor on 
non-x86 architectures when the legacy v1 ioctl is used.
- [Low] Typo in the bitfield name `vrew_clear_supported` (should be 
`verw_clear_supported`).
--

--- Patch [9]: [PATCH v1 09/13] mshv: define full processor and xsave feature 
masks ---
commit 758f4dc3eb51bb86e9e77dff7703639f92529960
Author: Wei Liu <[email protected]>

mshv: define full processor and xsave feature masks

Add the missing processor and xsave feature bit definitions and use
them when constructing the default disabled-feature mask, so legacy
SNP partition creation applies a complete, well-defined feature mask.

> diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> index 729916e1eacff..c81a8d0493c19 100644
> --- a/drivers/hv/mshv_root_main.c
> +++ b/drivers/hv/mshv_root_main.c
> @@ -2406,11 +2406,21 @@ static long mshv_ioctl_process_pt_flags(void __user 
> *user_arg, u64 *pt_flags,
[ ... ]
>       disabled_xsave->as_uint64 = U64_MAX;
>       disabled_xsave->xsave_support = 0;
>       disabled_xsave->xsaveopt_support = 0;
>       disabled_xsave->avx_support = 0;
> +     disabled_xsave->xsave_comp_support = 0;
> +     disabled_xsave->xsave_supervisor_support = 0;
>  #endif
>  
>       /* Check if user provided newer struct with feature fields */

[Severity: Medium]
Does this leave disabled_xsave uninitialized on non-x86 architectures when
using the legacy v1 ioctl?

When MSHV_PT_BIT_CPU_AND_XSAVE_FEATURES is not set on ARM64, the fallback
initialization that clears disabled_xsave->as_uint64 is skipped because it is
nested inside the v2 struct check block further down in
mshv_ioctl_process_pt_flags().

This leaves 8 bytes of uninitialized kernel stack in
creation_properties.disabled_processor_xsave_features (allocated in
mshv_ioctl_create_partition()), which is then passed to the hypervisor via
hv_call_create_partition().

This appears to have been introduced earlier in this patch series in the commit
"mshv: default to safe partition CPU features" when the original else block
clearing the legacy features was removed.

> diff --git a/include/hyperv/hvhdk.h b/include/hyperv/hvhdk.h
> index 691ac495a095d..54b0e671a028f 100644
> --- a/include/hyperv/hvhdk.h
> +++ b/include/hyperv/hvhdk.h
> @@ -231,7 +231,47 @@ union hv_partition_processor_features {
>               u64 fzlrep_movsb : 1;
>               u64 fsrep_stosb : 1;
>               u64 fsrep_cmpsb : 1;
> -             u64 reserved_bank1 : 42;
[ ... ]
> +             u64 sbpb_supported : 1;
> +             u64 ibpb_br_type_supported : 1;
> +             u64 srso_no_supported : 1;
> +             u64 srso_user_kernel_no_supported : 1;
> +             u64 vrew_clear_supported : 1;

[Severity: Low]
This isn't a bug, but there is a typo in the bitfield name vrew_clear_supported,
it should be verw_clear_supported.

> +             u64 tsa_l1_no_supported : 1;
> +             u64 tsa_sq_no_supported : 1;
> +             u64 lass_support : 1;
> +             u64 reserved_bank1 : 2;
>       } __packed;
>  };

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=9

Reply via email to