arm64: hyperv: Add Realm support for Hyper-V
Subsystems (4)
v6 cover arm64: hyperv: Add Realm support for Hyper-V
Realms (CoCo VMs on ARM) require host calls to be routed through the RMM (Realm Management Monitor) via the RSI (Realm Service Interface). This series implements most of the necessary changes to support Realms on Hyper-V.
One required change is not included in this series. The two buffers allocated via vzalloc() in netvsc_init_buf() cannot be decrypted in vmbus_establish_gpadl(). Currently only linearly mapped memory can be decrypted.
This patch series was tested by booting a Realm on Cobalt 200 running Windows. I tested 4KB and 64KB page size. I replaced vzalloc() in netvsc_init_buf() with alloc_pages_node() -> set_memory_decrypted() -> vmap() in my testing as a workaround for the issue mentioned above [1].
Changes since v1 [2]:
Patch 1: Add explicit padding to the RSI host call structure Patch 3: Change from a per-cpu pointer lazily allocated to an array
of host call structs indexed by cpu id
Patch 4: Align input_page + output_page allocation to PAGE_SIZE since
that is the smallest unit of memory that can be decrypted
~Remove KASAN tags before passing address to
set_memory_decrypted() since __is_lm_address() does pointer arithmetic.~ (reverted in v3)
Patch 5: Add a helper function to reduce repetition
Check for NULL before indexing into host call array
Changes since v2 [3]:
Patch 3: Remove hv_hostcall_free() and inline the logic for simplicity
Reorder edits to keep #include line at the end of the file
Patch 4: Remove kasan_reset_tag()
Changes since v3 [4]:
Rebased onto arm64 for-next/smccc-bus which includes moving RSI header files out of arch/arm64 [5]
Changes since v4 [6]:
Patch 1, 2, 4: Fix commit message to reflect the new header file names Patch 5: Remove extra blank line
Changes since v5 [7]:
Patch 2: Move Realm hypervisor detection out of the generic
arm_smccc_hypervisor_has_uuid() into hyperv_detect_via_smccc() so other SMCCC users are unaffected
Patch 3: Drop the <linux/arm-rsi-cmds.h> include, now added in patch 2
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/all/[email protected]/
[5] https://lore.kernel.org/all/[email protected]/
[6] https://lore.kernel.org/all/[email protected]/
[7] https://lore.kernel.org/all/[email protected]/
Kameron Carr (6):
arm64: rsi: Add RSI host call structure and helper function
arm64: hyperv: Detect Hyper-V via RSI host call in CCA Realms
arm64: hyperv: Add per-CPU RSI host call infrastructure for CCA Realms
Drivers: hv: Mark shared memory as decrypted for CCA Realms
arm64: hyperv: Route hypercalls through RSI host call in CCA Realms
arm64: hyperv: Implement hv_is_isolation_supported() for CCA Realms
arch/arm64/hyperv/hv_core.c | 155 +++++++++++++++++++++++------- arch/arm64/hyperv/mshyperv.c | 62 +++++++++++- arch/arm64/include/asm/mshyperv.h | 4 + drivers/hv/hv_common.c | 17 +++- include/asm-generic/mshyperv.h | 1 + include/linux/arm-rsi-cmds.h | 22 +++++ include/linux/arm-smccc-rsi.h | 7 ++ 7 files changed, 228 insertions(+), 40 deletions(-)
base-commit: bce57945f5e7207960b2bd567a6e880f90258ffb
Signature · 1 line
2.45.4
PATCH v6 1/6 arm64: rsi: Add RSI host call structure and helper function
Add struct rsi_host_call to arm-smccc-rsi.h, which represents the host call data structure used by the Realm Management Monitor (RMM) for the RSI_HOST_CALL interface. The structure contains a 16-bit immediate field and 31 general-purpose register values, aligned to 256 bytes as required by the CCA RMM specification.
Add rsi_host_call() static inline wrapper in arm-rsi-cmds.h that invokes SMC_RSI_HOST_CALL with the physical address of the host call structure. This will be used by Hyper-V guest code to route hypercalls through the RSI interface when running inside an Arm CCA Realm.
--- include/linux/arm-rsi-cmds.h | 22 ++++++++++++++++++++++ include/linux/arm-smccc-rsi.h | 7 +++++++ 2 files changed, 29 insertions(+)
include/linux/arm-rsi-cmds.h +22 -0
@@ -236,4 +236,26 @@ static inline unsigned long rsi_attestation_token_continue(phys_addr_t granule, return res.a0; } +/** +* rsi_host_call - Make a Host call. +* @host_call_struct: IPA of host call structure +* +* This call will fail if the IPA of the host call structure: +* * is not aligned to 256 bytes, +* * is not protected / encrypted, +* * is RIPAS_EMPTY +* +* Returns: +* On success, returns RSI_SUCCESS. +* Otherwise, returns an error code. +*/ +static inline unsigned long rsi_host_call (phys_addr_t host_call_struct) +{ +struct arm_smccc_res res; + +arm_smccc_smc (SMC_RSI_HOST_CALL , host_call_struct,0 ,0 ,0 ,0 ,0 ,0 , + &res); +return res.a0; +} +#endif /* __LINUX_ARM_RSI_CMDS_H_ */
include/linux/arm-smccc-rsi.h +7 -0
@@ -142,6 +142,13 @@ struct realm_config {*/ } __aligned(0x1000); +struct rsi_host_call { +u16 immediate; +u8 _padding[6 ]; +u64 gprs[31 ]; +}__aligned(256) ; +static_assert (sizeof (struct rsi_host_call ) ==256 ); +#endif /* __ASSEMBLER__ */ /*
Signature · 1 line
2.45.4
Dexuan Cui
maintainerRE: [PATCH v6 1/6] arm64: rsi: Add RSI host call structure and helper function
Quoted 18 lines
From: Kameron Carr <[email protected]>
Sent: Friday, October 30, 2026 5:14 PM
To: Dexuan Cui <[email protected]>; Haiyang Zhang <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; Mark.Rutland <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: [PATCH v6 1/6] arm64: rsi: Add RSI host call structure and helper functionAdd struct
rsi_host_calltoarm-smccc-rsi.h, which represents the host call data structure used by the Realm Management Monitor (RMM) for theRSI_HOST_CALLinterface. The structure contains a 16-bit immediate field and 31 general-purpose register values, aligned to 256 bytes as required by the CCA RMM specification.
Quoted 8 lines
Add
rsi_host_call()static inline wrapper inarm-rsi-cmds.hthat invokesSMC_RSI_HOST_CALLwith the physical address of the host call structure. This will be used by Hyper-V guest code to route hypercalls through the RSI interface when running inside an Arm CCA Realm.Reviewed-by Michael Kelley <[email protected]>Signed-off-by Kameron Carr <[email protected]>---
Catalin provided Reviewed-by to v5's patch #1, which is the same as v6's patch #1:
https://lore.kernel.org/all/[email protected]/
Re: [PATCH v6 1/6] arm64: rsi: Add RSI host call structure and helper function
Quoted 23 lines · Dexuan Cui
Quoted 23 lines
From: Kameron Carr <[email protected]>
Sent: Friday, October 30, 2026 5:14 PM
To: Dexuan Cui <[email protected]>; Haiyang Zhang <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; Mark.Rutland <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: [PATCH v6 1/6] arm64: rsi: Add RSI host call structure and helper functionAdd struct
rsi_host_calltoarm-smccc-rsi.h, which represents the host call data structure used by the Realm Management Monitor (RMM) for theRSI_HOST_CALLinterface. The structure contains a 16-bit immediate field and 31 general-purpose register values, aligned to 256 bytes as required by the CCA RMM specification.Add
rsi_host_call()static inline wrapper inarm-rsi-cmds.hthat invokesSMC_RSI_HOST_CALLwith the physical address of the host call structure. This will be used by Hyper-V guest code to route hypercalls through the RSI interface when running inside an Arm CCA Realm.
Quoted 7 lines
Quoted 3 lines
Reviewed-by Michael Kelley <[email protected]>Signed-off-by Kameron Carr <[email protected]>---
Catalin provided Reviewed-by to v5's patch #1, which is the same as v6's patch #1:
https://lore.kernel.org/all/[email protected]/
Yes, my review still stands.
PATCH v6 2/6 arm64: hyperv: Detect Hyper-V via RSI host call in CCA Realms
In reply to Kameron CarrWhen booting without ACPI, hyperv_detect_via_smccc() detects Hyper-V by querying the SMCCC vendor hypervisor UID. In an Arm CCA Realm the SMCCC call is handled by the RMM rather than by the hypervisor, so the query never reaches Hyper-V and detection fails.
When running in a Realm, forward ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID to the host with RSI_HOST_CALL instead, which is how Hyper-V hypercalls are issued from a Realm.
This is done in the Hyper-V code rather than in the generic arm_smccc_hypervisor_has_uuid() because the other users expect different behavior.
hyperv_init() is an early_initcall and runs before the secondary CPUs are brought up, so a single __initdata host call structure is used without locking.
ACPI-based detection and non-Realm guests are unaffected.
--- arch/arm64/hyperv/mshyperv.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
arch/arm64/hyperv/mshyperv.c +25 -0
@@ -11,6 +11,7 @@#include <linux/types.h> #include <linux/acpi.h> +#include <linux/arm-rsi-cmds.h> #include <linux/export.h> #include <linux/errno.h> #include <linux/version.h>
@@ -60,6 +61,27 @@ static bool __init hyperv_detect_via_acpi(void)#endif +/* +* In a Realm, the SMCCC call is handled by the RMM rather than by +* Hyper-V, so the vendor hypervisor UID query must be forwarded to the +* host with RSI_HOST_CALL, in the same way as hypercalls. +*/ +static bool __init hyperv_realm_has_uuid (const uuid_t *hyperv_uuid) +{ +static struct rsi_host_call hc__initdata ; +uuid_t uuid; + + hc.gprs[0 ] =ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID ; + +if (rsi_host_call (__pa_symbol (&hc)) !=RSI_SUCCESS || + hc.gprs[0 ] ==SMCCC_RET_NOT_SUPPORTED ) +return false; + + uuid =smccc_res_to_uuid (hc.gprs[0 ], hc.gprs[1 ], hc.gprs[2 ], + hc.gprs[3 ]); +return uuid_equal (&uuid, hyperv_uuid); +} +static bool __init hyperv_detect_via_smccc (void ) { uuid_t hyperv_uuid = UUID_INIT(
@@ -67,6 +89,9 @@ static bool __init hyperv_detect_via_smccc(void)0x75 ,0x6c ,0xef ,0x8e , 0x24, 0x70, 0x59, 0x16); +if (is_realm_world ()) +return hyperv_realm_has_uuid (&hyperv_uuid); +return arm_smccc_hypervisor_has_uuid (&hyperv_uuid); }
Signature · 1 line
2.45.4
Catalin Marinas
maintainerRe: [PATCH v6 2/6] arm64: hyperv: Detect Hyper-V via RSI host call in CCA Realms
Quoted 13 lines · Kameron Carr
When booting without ACPI,
hyperv_detect_via_smccc()detects Hyper-V by querying the SMCCC vendor hypervisor UID. In an Arm CCA Realm the SMCCC call is handled by the RMM rather than by the hypervisor, so the query never reaches Hyper-V and detection fails.When running in a Realm, forward
ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_IDto the host withRSI_HOST_CALLinstead, which is how Hyper-V hypercalls are issued from a Realm.This is done in the Hyper-V code rather than in the generic
arm_smccc_hypervisor_has_uuid()because the other users expect different behavior.
Quoted 7 lines
hyperv_init()is anearly_initcalland runs before the secondary CPUs are brought up, so a single__initdatahost call structure is used without locking.ACPI-based detection and non-Realm guests are unaffected.
Signed-off-by Kameron Carr <[email protected]>
This works for me, thanks. I replied to Dexuan clarifying my objection to v5 do the UUID check generically.
Signature · 1 line
Catalin
Re: [PATCH v6 2/6] arm64: hyperv: Detect Hyper-V via RSI host call in CCA Realms
Quoted 18 lines · Catalin Marinas
Quoted 17 lines · Kameron Carr
When booting without ACPI,
hyperv_detect_via_smccc()detects Hyper-V by querying the SMCCC vendor hypervisor UID. In an Arm CCA Realm the SMCCC call is handled by the RMM rather than by the hypervisor, so the query never reaches Hyper-V and detection fails.When running in a Realm, forward
ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_IDto the host withRSI_HOST_CALLinstead, which is how Hyper-V hypercalls are issued from a Realm.This is done in the Hyper-V code rather than in the generic
arm_smccc_hypervisor_has_uuid()because the other users expect different behavior.
hyperv_init()is anearly_initcalland runs before the secondary CPUs are brought up, so a single__initdatahost call structure is used without locking.
Quoted 6 lines
Quoted 3 lines
ACPI-based detection and non-Realm guests are unaffected.
Signed-off-by Kameron Carr <[email protected]>This works for me, thanks. I replied to Dexuan clarifying my objection to v5 do the UUID check generically.
Thank you for your review and suggestions.
Your clarification makes sense.
Is this a "Reviewed-by" or an "Acked-by"?
Signature · 2 lines
Regards, Kameron
Re: [PATCH v6 2/6] arm64: hyperv: Detect Hyper-V via RSI host call in CCA Realms
Quoted 23 lines · Kameron Carr
Quoted 22 lines · Catalin Marinas
Quoted 20 lines · Kameron Carr
When booting without ACPI,
hyperv_detect_via_smccc()detects Hyper-V by querying the SMCCC vendor hypervisor UID. In an Arm CCA Realm the SMCCC call is handled by the RMM rather than by the hypervisor, so the query never reaches Hyper-V and detection fails.When running in a Realm, forward
ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_IDto the host withRSI_HOST_CALLinstead, which is how Hyper-V hypercalls are issued from a Realm.This is done in the Hyper-V code rather than in the generic
arm_smccc_hypervisor_has_uuid()because the other users expect different behavior.
hyperv_init()is anearly_initcalland runs before the secondary CPUs are brought up, so a single__initdatahost call structure is used without locking.ACPI-based detection and non-Realm guests are unaffected.
Signed-off-by Kameron Carr <[email protected]>
Quoted 7 lines
Quoted 2 lines
This works for me, thanks. I replied to Dexuan clarifying my objection to v5 do the UUID check generically.
Thank you for your review and suggestions.
Your clarification makes sense.Is this a "Reviewed-by" or an "Acked-by"?
I don't usually ack the hyperv patches as I don't know enough about it but given that I commented on this particular patch in v5:
Signature · 1 line
Catalin
PATCH v6 3/6 arm64: hyperv: Add per-CPU RSI host call infrastructure for CCA Realms
In reply to Kameron CarrArm CCA Realms cannot issue Hyper-V hypercalls via HVC; the guest must route them through the RSI_HOST_CALL interface, which takes the IPA of a per-CPU rsi_host_call structure as its argument.
Add hv_hostcall_array as a per-CPU struct array and allocate it during hyperv_init(). The allocation is gated on is_realm_world() so non-Realm arm64 Hyper-V guests pay no memory cost.
--- arch/arm64/hyperv/mshyperv.c | 27 +++++++++++++++++++++++++-- arch/arm64/include/asm/mshyperv.h | 4 ++++ 2 files changed, 29 insertions(+), 2 deletions(-)
arch/arm64/hyperv/mshyperv.c +25 -2
@@ -14,12 +14,16 @@#include <linux/arm-rsi-cmds.h> #include <linux/export.h> #include <linux/errno.h> +#include <linux/slab.h> #include <linux/version.h> #include <linux/cpuhotplug.h> #include <asm/mshyperv.h> static bool hyperv_initialized; +struct rsi_host_call *hv_hostcall_array; +EXPORT_SYMBOL_GPL (hv_hostcall_array); +int hv_get_hypervisor_version (union hv_hypervisor_version_info *info) { hv_get_vpreg_128(HV_REGISTER_HYPERVISOR_VERSION,
@@ -110,6 +114,20 @@ static int __init hyperv_init(void)if (!hyperv_detect_via_acpi () && !hyperv_detect_via_smccc ())return 0 ; +/* +* The RSI host-call buffers are only ever used when +* is_realm_world() is true. Skip the allocation on non-Realm +* guests. A single contiguous array of nr_cpu_ids entries is +* allocated; each CPU indexes into it by its processor ID. +*/ +if (is_realm_world ()) { + hv_hostcall_array =kcalloc (nr_cpu_ids, +sizeof (struct rsi_host_call ), +GFP_KERNEL ); +if (!hv_hostcall_array) +return -ENOMEM ; + } +/* Setup the guest ID */ guest_id =hv_generate_guest_id (LINUX_VERSION_CODE );hv_set_vpreg (HV_REGISTER_GUEST_OS_ID , guest_id);
@@ -131,13 +149,13 @@ static int __init hyperv_init(void) ret =hv_common_init ();if (ret) -return ret; + goto free_hostcall_mem; ret =cpuhp_setup_state (CPUHP_AP_HYPERV_ONLINE ,"arm64/hyperv_init:online" , hv_common_cpu_init, hv_common_cpu_die);if (ret <0 ) {hv_common_free (); -return ret; + goto free_hostcall_mem; }if (ms_hyperv.priv_high &HV_ACCESS_PARTITION_ID )
@@ -150,6 +168,11 @@ static int __init hyperv_init(void) hyperv_initialized = true;return 0 ; + +free_hostcall_mem: +kfree (hv_hostcall_array); + hv_hostcall_array =NULL ; +return ret; }early_initcall (hyperv_init);
arch/arm64/include/asm/mshyperv.h +4 -0
@@ -61,6 +61,10 @@ static inline u64 hv_get_non_nested_msr(unsigned int reg) ARM_SMCCC_OWNER_VENDOR_HYP, \ HV_SMCCC_FUNC_NUMBER) +/* Per-CPU-indexed RSI host call structures for CCA Realms */ +struct rsi_host_call ; +extern struct rsi_host_call *hv_hostcall_array; +#include <asm-generic/mshyperv.h> #endif
Signature · 1 line
2.45.4
RE: [PATCH v6 3/6] arm64: hyperv: Add per-CPU RSI host call infrastructure for CCA Realms
From: Kameron Carr <[email protected]> Sent: Friday, October 30, 2026 5:14 PM
Quoted 7 lines
Arm CCA Realms cannot issue Hyper-V hypercalls via HVC; the guest must route them through the
RSI_HOST_CALLinterface, which takes the IPA of a per-CPUrsi_host_callstructure as its argument.Add
hv_hostcall_arrayas a per-CPU struct array and allocate it duringhyperv_init().
A quibble: This statement is a bit misleading. I think you mean it is a global array with an entry for each CPU. The term "per-CPU" typically means something allocated out of the per-CPU area.
Michael
Quoted 100 lines
The allocation is gated on
is_realm_world()so non-Realm arm64 Hyper-V guests pay no memory cost.Reviewed-by Michael Kelley <[email protected]>Signed-off-by Kameron Carr <[email protected]>--- arch/arm64/hyperv/mshyperv.c | 27 +++++++++++++++++++++++++-- arch/arm64/include/asm/mshyperv.h | 4 ++++ 2 files changed, 29 insertions(+), 2 deletions(-)arch/arm64/hyperv/mshyperv.c +20
-2@@ -14,12 +14,16 @@#include <linux/arm-rsi-cmds.h> #include <linux/export.h> #include <linux/errno.h> +#include <linux/slab.h> #include <linux/version.h> #include <linux/cpuhotplug.h> #include <asm/mshyperv.h> static bool hyperv_initialized; +struct rsi_host_call *hv_hostcall_array; +EXPORT_SYMBOL_GPL (hv_hostcall_array); +int hv_get_hypervisor_version (union hv_hypervisor_version_info *info) { hv_get_vpreg_128(HV_REGISTER_HYPERVISOR_VERSION,@@ -110,6 +114,20 @@ static int __init hyperv_init(void)if (!hyperv_detect_via_acpi () && !hyperv_detect_via_smccc ())return 0 ; +/* +* The RSI host-call buffers are only ever used when +* is_realm_world() is true. Skip the allocation on non-Realm +* guests. A single contiguous array of nr_cpu_ids entries is +* allocated; each CPU indexes into it by its processor ID. +*/ +if (is_realm_world ()) { + hv_hostcall_array =kcalloc (nr_cpu_ids, +sizeof (struct rsi_host_call ), +GFP_KERNEL ); +if (!hv_hostcall_array) +return -ENOMEM ; + } +/* Setup the guest ID */ guest_id =hv_generate_guest_id (LINUX_VERSION_CODE );hv_set_vpreg (HV_REGISTER_GUEST_OS_ID , guest_id);@@ -131,13 +149,13 @@ static int __init hyperv_init(void) ret =hv_common_init ();if (ret) -return ret; + goto free_hostcall_mem; ret =cpuhp_setup_state (CPUHP_AP_HYPERV_ONLINE ,"arm64/hyperv_init:online" , hv_common_cpu_init, hv_common_cpu_die);if (ret <0 ) {hv_common_free (); -return ret; + goto free_hostcall_mem; }arch/arm64/hyperv/mshyperv.c +5
-0if (ms_hyperv.priv_high &HV_ACCESS_PARTITION_ID )@@ -150,6 +168,11 @@ static int __init hyperv_init(void) hyperv_initialized = true;return 0 ; + +free_hostcall_mem: +kfree (hv_hostcall_array); + hv_hostcall_array =NULL ; +return ret; }early_initcall (hyperv_init);arch/arm64/include/asm/mshyperv.h +4
-1@@ -61,6 +61,10 @@ static inline u64 hv_get_non_nested_msr(unsigned int reg) ARM_SMCCC_OWNER_VENDOR_HYP, \ HV_SMCCC_FUNC_NUMBER) +/* Per-CPU-indexed RSI host call structures for CCA Realms */ +struct rsi_host_call ; +extern struct rsi_host_call *hv_hostcall_array; +#include <asm-generic/mshyperv.h> #endif --2.45.4
Re: [PATCH v6 3/6] arm64: hyperv: Add per-CPU RSI host call infrastructure for CCA Realms
Quoted 6 lines · Michael Kelley
From: Kameron Carr <[email protected]> Sent: Friday, October 30, 2026 5:14 PM
Quoted 5 lines
Arm CCA Realms cannot issue Hyper-V hypercalls via HVC; the guest must route them through the
RSI_HOST_CALLinterface, which takes the IPA of a per-CPUrsi_host_callstructure as its argument.
Quoted 6 lines
Quoted 2 lines
Add
hv_hostcall_arrayas a per-CPU struct array and allocate it duringhyperv_init().A quibble: This statement is a bit misleading. I think you mean it is a global array with an entry for each CPU. The term "per-CPU" typically means something allocated out of the per-CPU area.
I agree. Earlier versions of the patch did use a per-CPU struct but it was changed to a global array because the structure was small enough.
This series has already been applied to hyperv-next, but I can reach out to Wei about editing the commit messages.
Signature · 2 lines
Regards, Kameron
Quoted 102 lines
Michael
Quoted 100 lines
The allocation is gated on
is_realm_world()so non-Realm arm64 Hyper-V guests pay no memory cost.Reviewed-by Michael Kelley <[email protected]>Signed-off-by Kameron Carr <[email protected]>--- arch/arm64/hyperv/mshyperv.c | 27 +++++++++++++++++++++++++-- arch/arm64/include/asm/mshyperv.h | 4 ++++ 2 files changed, 29 insertions(+), 2 deletions(-)arch/arm64/hyperv/mshyperv.c +20
-2@@ -14,12 +14,16 @@#include <linux/arm-rsi-cmds.h> #include <linux/export.h> #include <linux/errno.h> +#include <linux/slab.h> #include <linux/version.h> #include <linux/cpuhotplug.h> #include <asm/mshyperv.h> static bool hyperv_initialized; +struct rsi_host_call *hv_hostcall_array; +EXPORT_SYMBOL_GPL (hv_hostcall_array); +int hv_get_hypervisor_version (union hv_hypervisor_version_info *info) { hv_get_vpreg_128(HV_REGISTER_HYPERVISOR_VERSION,@@ -110,6 +114,20 @@ static int __init hyperv_init(void)if (!hyperv_detect_via_acpi () && !hyperv_detect_via_smccc ())return 0 ; +/* +* The RSI host-call buffers are only ever used when +* is_realm_world() is true. Skip the allocation on non-Realm +* guests. A single contiguous array of nr_cpu_ids entries is +* allocated; each CPU indexes into it by its processor ID. +*/ +if (is_realm_world ()) { + hv_hostcall_array =kcalloc (nr_cpu_ids, +sizeof (struct rsi_host_call ), +GFP_KERNEL ); +if (!hv_hostcall_array) +return -ENOMEM ; + } +/* Setup the guest ID */ guest_id =hv_generate_guest_id (LINUX_VERSION_CODE );hv_set_vpreg (HV_REGISTER_GUEST_OS_ID , guest_id);@@ -131,13 +149,13 @@ static int __init hyperv_init(void) ret =hv_common_init ();if (ret) -return ret; + goto free_hostcall_mem; ret =cpuhp_setup_state (CPUHP_AP_HYPERV_ONLINE ,"arm64/hyperv_init:online" , hv_common_cpu_init, hv_common_cpu_die);if (ret <0 ) {hv_common_free (); -return ret; + goto free_hostcall_mem; }arch/arm64/hyperv/mshyperv.c +5
-0if (ms_hyperv.priv_high &HV_ACCESS_PARTITION_ID )@@ -150,6 +168,11 @@ static int __init hyperv_init(void) hyperv_initialized = true;return 0 ; + +free_hostcall_mem: +kfree (hv_hostcall_array); + hv_hostcall_array =NULL ; +return ret; }early_initcall (hyperv_init);arch/arm64/include/asm/mshyperv.h +4
-1@@ -61,6 +61,10 @@ static inline u64 hv_get_non_nested_msr(unsigned int reg) ARM_SMCCC_OWNER_VENDOR_HYP, \ HV_SMCCC_FUNC_NUMBER) +/* Per-CPU-indexed RSI host call structures for CCA Realms */ +struct rsi_host_call ; +extern struct rsi_host_call *hv_hostcall_array; +#include <asm-generic/mshyperv.h> #endif --2.45.4
PATCH v6 4/6 Drivers: hv: Mark shared memory as decrypted for CCA Realms
In reply to Kameron CarrIn hv_common_cpu_init(), the per-CPU hypercall input/output pages need to be marked as decrypted (shared) for confidential VM isolation types. This is already done for SNP and TDX isolation; extend the same handling to Arm CCA Realm guests so that the host hypervisor can access the shared hypercall buffers.
is_realm_world() is declared in include/linux/arm-rsi-cmds.h which only builds on arm64 (it includes <asm/memory.h>), so using it directly in the arch-neutral drivers/hv/hv_common.c would break the x86 build. Introduce a Hyper-V-specific helper following the established hv_isolation_type_snp() / hv_isolation_type_tdx() pattern.
On architectures other than arm64 the weak default keeps the existing behaviour.
--- arch/arm64/hyperv/mshyperv.c | 5 +++++ drivers/hv/hv_common.c | 17 +++++++++++++---- include/asm-generic/mshyperv.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-)
arch/arm64/hyperv/mshyperv.c +5 -0
@@ -182,3 +182,8 @@ bool hv_is_hyperv_initialized(void)return hyperv_initialized; }EXPORT_SYMBOL_GPL (hv_is_hyperv_initialized); + +bool hv_isolation_type_cca (void ) +{ +return is_realm_world (); +}
drivers/hv/hv_common.c +13 -4
@@ -476,6 +476,7 @@ int hv_common_cpu_init(unsigned int cpu)u64 msr_vp_index;gfp_t flags;const int pgcount =hv_output_page_exists () ?2 :1 ; +const size_t alloc_size =ALIGN ((size_t )pgcount *HV_HYP_PAGE_SIZE ,PAGE_SIZE );void *mem;int ret =0 ;
@@ -489,7 +490,7 @@ int hv_common_cpu_init(unsigned int cpu)* online and then taken offline */ if (!*inputarg) { - mem =kmalloc_array (pgcount,HV_HYP_PAGE_SIZE , flags); + mem =kmalloc (alloc_size, flags);if (!mem)return -ENOMEM ;
@@ -499,14 +500,16 @@ int hv_common_cpu_init(unsigned int cpu) }if (!ms_hyperv.paravisor_present && - (hv_isolation_type_snp () ||hv_isolation_type_tdx ())) { - ret =set_memory_decrypted ((unsigned long )mem, pgcount); + (hv_isolation_type_snp () ||hv_isolation_type_tdx () || +hv_isolation_type_cca ())) { + ret =set_memory_decrypted ((unsigned long )mem, + alloc_size >>PAGE_SHIFT );if (ret) {/* It may be unsafe to free 'mem' */ return ret; } -memset (mem,0x00 , pgcount *HV_HYP_PAGE_SIZE ); +memset (mem,0x00 , alloc_size); }/*
@@ -666,6 +669,12 @@ bool __weak hv_isolation_type_tdx(void) }EXPORT_SYMBOL_GPL (hv_isolation_type_tdx); +bool __weak hv_isolation_type_cca (void ) +{ +return false; +} +EXPORT_SYMBOL_GPL (hv_isolation_type_cca); +void __weak hv_setup_vmbus_handler (void (*handler)(void )) { }
include/asm-generic/mshyperv.h +1 -0
@@ -79,6 +79,7 @@ u64 hv_do_fast_hypercall16(u16 control, u64 input1, u64 input2);bool hv_isolation_type_snp (void );bool hv_isolation_type_tdx (void ); +bool hv_isolation_type_cca (void );/* * On architectures where Hyper-V doesn't support AEOI (e.g., ARM64),
Signature · 1 line
2.45.4
[email protected]
AI reviewRe: [PATCH v6 4/6] Drivers: hv: Mark shared memory as decrypted for CCA Realms
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] hv: arm64: set_memory_decrypted() in hv_common_cpu_init() hits BBML3 -EBUSY --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] hv: arm64: set_memory_decrypted() in hv_common_cpu_init() hits BBML3 -EBUSY --
commit 8d15e623ca43bf983a70fccbb187c60423dd18ef
Author: Kameron Carr <[email protected]>
Drivers: hv: Mark shared memory as decrypted for CCA Realms
This commit introduces hv_isolation_type_cca() and extends hv_common_cpu_init() to mark the per-CPU hypercall input and output pages as decrypted on Arm CCA Realm guests. It also aligns the hypercall buffer allocation size to PAGE_SIZE when calling set_memory_decrypted().
Quoted 25 lines
drivers/hv/hv_common.c +2
-1@@ -476,6 +476,7 @@ int hv_common_cpu_init(unsigned int cpu)u64 msr_vp_index;gfp_t flags;const int pgcount =hv_output_page_exists () ?2 :1 ; +const size_t alloc_size =ALIGN ((size_t )pgcount *HV_HYP_PAGE_SIZE ,PAGE_SIZE );void *mem;int ret =0 ;@@ -489,7 +490,7 @@ int hv_common_cpu_init(unsigned int cpu)* online and then taken offline */ if (!*inputarg) { - mem =kmalloc_array (pgcount,HV_HYP_PAGE_SIZE , flags); + mem =kmalloc (alloc_size, flags);if (!mem)return -ENOMEM ;@@ -499,14 +500,16 @@ int hv_common_cpu_init(unsigned int cpu) } if (!ms_hyperv.paravisor_present &&
drivers/hv/hv_common.c int hv_common_cpu_init(unsigned int cpu) · line 510
Quoted 10 lines
drivers/hv/hv_common.c +4
-2- (hv_isolation_type_snp() || hv_isolation_type_tdx())) { - ret =set_memory_decrypted ((unsigned long )mem, pgcount); + (hv_isolation_type_snp() || hv_isolation_type_tdx() || + hv_isolation_type_cca())) { + ret =set_memory_decrypted ((unsigned long )mem, + alloc_size >>PAGE_SHIFT );if (ret) {/* It may be unsafe to free 'mem' */ \return ret; }
[Severity: High]
Can calling set_memory_decrypted() from hv_common_cpu_init() fail with -EBUSY and prevent secondary CPUs from coming online on BBML3-capable arm64 systems?
On arm64, when the boot CPU supports BBML3 and debug_pagealloc is disabled, paging_init() -> map_mem() sets linear_map_requires_bbml3 = true and maps the linear region with block/contiguous descriptors because is_realm_world() makes can_set_direct_map() return true.
In arch/arm64/hyperv/mshyperv.c, hyperv_init() runs as an early_initcall() during do_pre_smp_initcalls() and registers hv_common_cpu_init() for CPUHP_AP_HYPERV_ONLINE:
ret = cpuhp_setup_state(CPUHP_AP_HYPERV_ONLINE, "arm64/hyperv_init:online", hv_common_cpu_init, hv_common_cpu_die);
Next, smp_init() calls bringup_nonboot_cpus() before smp_cpus_done() -> setup_system_features() -> setup_system_capabilities() finalizes the ARM64_HAS_BBML3 capability. During bringup_nonboot_cpus(), each secondary CPU is marked online in secondary_start_kernel() (making num_online_cpus() > 1) and then executes CPUHP_AP_HYPERV_ONLINE -> hv_common_cpu_init() while system_supports_bbml3() and system_capabilities_finalized() are still false.
That leads to the following call chain on the secondary CPU:
hv_common_cpu_init()
set_memory_decrypted()
realm_set_memory_decrypted()
__set_memory_enc_dec()
__change_memory_common()
update_range_prot()
split_kernel_leaf_mapping()In arch/arm64/mm/mmu.c:split_kernel_leaf_mapping(), splitting the linear map in this window triggers a warning and returns -EBUSY:
if (!linear_map_requires_bbml3 || is_kfence_address((void *)start))
return 0;
if (!system_supports_bbml3()) {
if (system_capabilities_finalized())
return 0;
if (WARN_ON(!page_alloc_available))
return -EBUSY;
/*
* Boot-time: Started secondary cpus but don't know if they
* support BBML3 yet. Can't allow splitting in this window
* in case they don't.
*/
if (WARN_ON(num_online_cpus() > 1))
return -EBUSY;
}When split_kernel_leaf_mapping() returns -EBUSY, hv_common_cpu_init() leaks the mem buffer and returns -EBUSY from the CPUHP_AP_HYPERV_ONLINE callback, aborting secondary CPU bringup.
Should the per-CPU hypercall buffers for possible CPUs be allocated and decrypted earlier on the boot CPU (for example in hv_common_init() while num_online_cpus() == 1), or after system capabilities have been finalized?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
RE: [PATCH v6 4/6] Drivers: hv: Mark shared memory as decrypted for CCA Realms
In reply to Kameron CarrFrom: Kameron Carr <[email protected]> Sent: Friday, October 30, 2026 5:14 PM
Quoted 59 lines
In
hv_common_cpu_init(), the per-CPU hypercall input/output pages need to be marked as decrypted (shared) for confidential VM isolation types. This is already done for SNP and TDX isolation; extend the same handling to Arm CCA Realm guests so that the host hypervisor can access the shared hypercall buffers.
is_realm_world()is declared ininclude/linux/arm-rsi-cmds.hwhich only builds on arm64 (it includes <asm/memory.h>), so using it directly in the arch-neutraldrivers/hv/hv_common.cwould break the x86 build. Introduce a Hyper-V-specific helper following the establishedhv_isolation_type_snp()/hv_isolation_type_tdx()pattern.On architectures other than arm64 the weak default keeps the existing behaviour.
Reviewed-by Michael Kelley <[email protected]>Signed-off-by Kameron Carr <[email protected]>--- arch/arm64/hyperv/mshyperv.c | 5 +++++ drivers/hv/hv_common.c | 17 +++++++++++++---- include/asm-generic/mshyperv.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-)arch/arm64/hyperv/mshyperv.c +5
-0@@ -182,3 +182,8 @@ bool hv_is_hyperv_initialized(void)return hyperv_initialized; }EXPORT_SYMBOL_GPL (hv_is_hyperv_initialized); + +bool hv_isolation_type_cca (void ) +{ +return is_realm_world (); +}drivers/hv/hv_common.c +2
-1@@ -476,6 +476,7 @@ int hv_common_cpu_init(unsigned int cpu)u64 msr_vp_index;gfp_t flags;const int pgcount =hv_output_page_exists () ?2 :1 ; +const size_t alloc_size =ALIGN ((size_t )pgcount *HV_HYP_PAGE_SIZE ,PAGE_SIZE );void *mem;int ret =0 ;@@ -489,7 +490,7 @@ int hv_common_cpu_init(unsigned int cpu)* online and then taken offline */ if (!*inputarg) { - mem =kmalloc_array (pgcount,HV_HYP_PAGE_SIZE , flags); + mem =kmalloc (alloc_size, flags);if (!mem)return -ENOMEM ;
drivers/hv/hv_common.c int hv_common_cpu_init(unsigned int cpu) · line 504
Quoted 7 lines
drivers/hv/hv_common.c +2
-2@@ -499,14 +500,16 @@ int hv_common_cpu_init(unsigned int cpu) }if (!ms_hyperv.paravisor_present && - (hv_isolation_type_snp () ||hv_isolation_type_tdx ())) { - ret =set_memory_decrypted ((unsigned long )mem, pgcount); + (hv_isolation_type_snp () ||hv_isolation_type_tdx () || +hv_isolation_type_cca ())) {
Could this big "if" statement use "hv_is_isolation_supported()" instead of explicitly testing for each CoCo VM type? I ask partly because Mukesh Rathor has just submitted a patch [1] that introduces a new function that does something almost exactly the same as hv_is_isolation_supported() and uses it here.
You don't provide the non-stub hv_is_isolation_supported() until Patch 6 of this series, but the weak stub should allow everything to build if a bisection splits this patch series.
Michael
Quoted 41 lines
drivers/hv/hv_common.c +9
-1+ ret =set_memory_decrypted ((unsigned long )mem, + alloc_size >>PAGE_SHIFT );if (ret) {/* It may be unsafe to free 'mem' */ return ret; } -memset (mem,0x00 , pgcount *HV_HYP_PAGE_SIZE ); +memset (mem,0x00 , alloc_size); }/* @@ -666,6 +669,12 @@ bool __weak hv_isolation_type_tdx(void) }EXPORT_SYMBOL_GPL (hv_isolation_type_tdx); +bool __weak hv_isolation_type_cca (void ) +{ +return false; +} +EXPORT_SYMBOL_GPL (hv_isolation_type_cca); +void __weak hv_setup_vmbus_handler (void (*handler)(void )) { }include/asm-generic/mshyperv.h +1
-0@@ -79,6 +79,7 @@ u64 hv_do_fast_hypercall16(u16 control, u64 input1, u64 input2);bool hv_isolation_type_snp (void );bool hv_isolation_type_tdx (void ); +bool hv_isolation_type_cca (void );/* * On architectures where Hyper-V doesn't support AEOI (e.g., ARM64),
--
2.45.4
Re: [PATCH v6 4/6] Drivers: hv: Mark shared memory as decrypted for CCA Realms
Quoted 74 lines · Michael Kelley
From: Kameron Carr <[email protected]> Sent: Friday, October 30, 2026 5:14 PM
Quoted 59 lines
In
hv_common_cpu_init(), the per-CPU hypercall input/output pages need to be marked as decrypted (shared) for confidential VM isolation types. This is already done for SNP and TDX isolation; extend the same handling to Arm CCA Realm guests so that the host hypervisor can access the shared hypercall buffers.
is_realm_world()is declared ininclude/linux/arm-rsi-cmds.hwhich only builds on arm64 (it includes <asm/memory.h>), so using it directly in the arch-neutraldrivers/hv/hv_common.cwould break the x86 build. Introduce a Hyper-V-specific helper following the establishedhv_isolation_type_snp()/hv_isolation_type_tdx()pattern.On architectures other than arm64 the weak default keeps the existing behaviour.
Reviewed-by Michael Kelley <[email protected]>Signed-off-by Kameron Carr <[email protected]>--- arch/arm64/hyperv/mshyperv.c | 5 +++++ drivers/hv/hv_common.c | 17 +++++++++++++---- include/asm-generic/mshyperv.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-)arch/arm64/hyperv/mshyperv.c +5
-0@@ -182,3 +182,8 @@ bool hv_is_hyperv_initialized(void)return hyperv_initialized; }EXPORT_SYMBOL_GPL (hv_is_hyperv_initialized); + +bool hv_isolation_type_cca (void ) +{ +return is_realm_world (); +}drivers/hv/hv_common.c +2
-1@@ -476,6 +476,7 @@ int hv_common_cpu_init(unsigned int cpu)u64 msr_vp_index;gfp_t flags;const int pgcount =hv_output_page_exists () ?2 :1 ; +const size_t alloc_size =ALIGN ((size_t )pgcount *HV_HYP_PAGE_SIZE ,PAGE_SIZE );void *mem;int ret =0 ;@@ -489,7 +490,7 @@ int hv_common_cpu_init(unsigned int cpu)* online and then taken offline */ if (!*inputarg) { - mem =kmalloc_array (pgcount,HV_HYP_PAGE_SIZE , flags); + mem =kmalloc (alloc_size, flags);if (!mem)return -ENOMEM ;drivers/hv/hv_common.c int hv_common_cpu_init(unsigned int cpu) · line 504
Quoted 7 lines
drivers/hv/hv_common.c +2
-2@@ -499,14 +500,16 @@ int hv_common_cpu_init(unsigned int cpu) }if (!ms_hyperv.paravisor_present && - (hv_isolation_type_snp () ||hv_isolation_type_tdx ())) { - ret =set_memory_decrypted ((unsigned long )mem, pgcount); + (hv_isolation_type_snp () ||hv_isolation_type_tdx () || +hv_isolation_type_cca ())) {Could this big "if" statement use "
hv_is_isolation_supported()" instead of explicitly testing for each CoCo VM type? I ask partly because Mukesh Rathor has just submitted a patch [1] that introduces a new function that does something almost exactly the same ashv_is_isolation_supported()and uses it here.
Quoted 3 lines
You don't provide the non-stub
hv_is_isolation_supported()until Patch 6 of this series, but the weak stub should allow everything to build if a bisection splits this patch series.
Including your response to Mukesh for context:
Quoted 6 lines
Any reason not to use
hv_is_isolation_supported()? Your new function seems conceptually equivalent, though at a detailed level it handles VBS isolation differently fromhv_is_isolation_supported(). But I don't think including VBS isolation here is a problem sinceset_memory_decrypted()is a no-op with VBS isolation.
I'm not fully convinced that calling set_memory_decrypted() is always a no-op for VBS.
I see that on VBS VMs, ms_hyperv_init_platform() calls hv_vtom_init(). If set_memory_decrypted() calls hv_mark_gpa_visibility(), you will try to use the inputarg before it has been initialized.
Please let me know if my understanding is incorrect.
Signature · 2 lines
Regards, Kameron
Quoted 45 lines
Michael
[1] https://lore.kernel.org/linux-hyperv/[email protected]/
Quoted 41 lines
drivers/hv/hv_common.c +9
-1+ ret =set_memory_decrypted ((unsigned long )mem, + alloc_size >>PAGE_SHIFT );if (ret) {/* It may be unsafe to free 'mem' */ return ret; } -memset (mem,0x00 , pgcount *HV_HYP_PAGE_SIZE ); +memset (mem,0x00 , alloc_size); }/* @@ -666,6 +669,12 @@ bool __weak hv_isolation_type_tdx(void) }EXPORT_SYMBOL_GPL (hv_isolation_type_tdx); +bool __weak hv_isolation_type_cca (void ) +{ +return false; +} +EXPORT_SYMBOL_GPL (hv_isolation_type_cca); +void __weak hv_setup_vmbus_handler (void (*handler)(void )) { }include/asm-generic/mshyperv.h +1
-0@@ -79,6 +79,7 @@ u64 hv_do_fast_hypercall16(u16 control, u64 input1, u64 input2);bool hv_isolation_type_snp (void );bool hv_isolation_type_tdx (void ); +bool hv_isolation_type_cca (void );/* * On architectures where Hyper-V doesn't support AEOI (e.g., ARM64),
--
2.45.4
RE: [PATCH v6 4/6] Drivers: hv: Mark shared memory as decrypted for CCA Realms
From: Kameron Carr <[email protected]> Sent: Wednesday, November 11, 2026 2:37 PM
Quoted 88 lines · Michael Kelley
Quoted 74 lines
From: Kameron Carr <[email protected]> Sent: Friday, October 30, 2026 5:14 PM
Quoted 59 lines
In
hv_common_cpu_init(), the per-CPU hypercall input/output pages need to be marked as decrypted (shared) for confidential VM isolation types. This is already done for SNP and TDX isolation; extend the same handling to Arm CCA Realm guests so that the host hypervisor can access the shared hypercall buffers.
is_realm_world()is declared ininclude/linux/arm-rsi-cmds.hwhich only builds on arm64 (it includes <asm/memory.h>), so using it directly in the arch-neutraldrivers/hv/hv_common.cwould break the x86 build. Introduce a Hyper-V-specific helper following the establishedhv_isolation_type_snp()/hv_isolation_type_tdx()pattern.On architectures other than arm64 the weak default keeps the existing behaviour.
Reviewed-by Michael Kelley <[email protected]>Signed-off-by Kameron Carr <[email protected]>--- arch/arm64/hyperv/mshyperv.c | 5 +++++ drivers/hv/hv_common.c | 17 +++++++++++++---- include/asm-generic/mshyperv.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-)arch/arm64/hyperv/mshyperv.c +5
-0@@ -182,3 +182,8 @@ bool hv_is_hyperv_initialized(void)return hyperv_initialized; }EXPORT_SYMBOL_GPL (hv_is_hyperv_initialized); + +bool hv_isolation_type_cca (void ) +{ +return is_realm_world (); +}drivers/hv/hv_common.c +2
-1@@ -476,6 +476,7 @@ int hv_common_cpu_init(unsigned int cpu)u64 msr_vp_index;gfp_t flags;const int pgcount =hv_output_page_exists () ?2 :1 ; +const size_t alloc_size =ALIGN ((size_t )pgcount *HV_HYP_PAGE_SIZE ,PAGE_SIZE );void *mem;int ret =0 ;@@ -489,7 +490,7 @@ int hv_common_cpu_init(unsigned int cpu)* online and then taken offline */ if (!*inputarg) { - mem =kmalloc_array (pgcount,HV_HYP_PAGE_SIZE , flags); + mem =kmalloc (alloc_size, flags);if (!mem)return -ENOMEM ;drivers/hv/hv_common.c int hv_common_cpu_init(unsigned int cpu) · line 504
Quoted 7 lines
drivers/hv/hv_common.c +2
-2@@ -499,14 +500,16 @@ int hv_common_cpu_init(unsigned int cpu) }if (!ms_hyperv.paravisor_present && - (hv_isolation_type_snp () ||hv_isolation_type_tdx ())) { - ret =set_memory_decrypted ((unsigned long )mem, pgcount); + (hv_isolation_type_snp () ||hv_isolation_type_tdx () || +hv_isolation_type_cca ())) {Could this big "if" statement use "
hv_is_isolation_supported()" instead of explicitly testing for each CoCo VM type? I ask partly because Mukesh Rathor has just submitted a patch [1] that introduces a new function that does something almost exactly the same ashv_is_isolation_supported()and uses it here.Quoted 3 lines
You don't provide the non-stub
hv_is_isolation_supported()until Patch 6 of this series, but the weak stub should allow everything to build if a bisection splits this patch series.Including your response to Mukesh for context:
Quoted 6 lines
Any reason not to use
hv_is_isolation_supported()? Your new function seems conceptually equivalent, though at a detailed level it handles VBS isolation differently fromhv_is_isolation_supported(). But I don't think including VBS isolation here is a problem sinceset_memory_decrypted()is a no-op with VBS isolation.
Quoted 8 lines
I'm not fully convinced that calling
set_memory_decrypted()is always a no-op for VBS.I see that on VBS VMs,
ms_hyperv_init_platform()callshv_vtom_init(). Ifset_memory_decrypted()callshv_mark_gpa_visibility(), you will try to use the inputarg before it has been initialized.Please let me know if my understanding is incorrect.
You are right. In general, it *is* okay to call set_memory_decrypted/encrypted() with VBS isolation. The decrypt/encrypt paths go through all the normal machinery, including making the Hyper-V hypercalls. But the net result is no change in the guest. PTEs remain unchanged and the vTOM bit is not added to physical addresses. In that sense, it is a no-op, which is what I was remembering. But in this case, that doesn't work because of the scenario you point out. This call to set_memory_decrypted() must be skipped for VBS isolation. I may do a small patch to add a comment to the code here identifying this as an exception.
The fully-enlightened (no paravisor) cases for SNP and TDX are good because they don't call hv_vtom_init(). In those cases, set_memory_decrypted() uses the "native" callbacks to update the hypervisor. Those native callbacks don't know anything about Hyper-V or the per-cpu input page, and so don't have the chicken-and-egg problem that VBS isolation has.
I need to go review again how all this works for CCA. :-)
Thanks,
Michael
Re: [PATCH v6 4/6] Drivers: hv: Mark shared memory as decrypted for CCA Realms
In reply to Michael KelleyQuoted 74 lines · Michael Kelley
From: Kameron Carr <[email protected]> Sent: Friday, October 30, 2026 5:14 PM
Quoted 59 lines
In
hv_common_cpu_init(), the per-CPU hypercall input/output pages need to be marked as decrypted (shared) for confidential VM isolation types. This is already done for SNP and TDX isolation; extend the same handling to Arm CCA Realm guests so that the host hypervisor can access the shared hypercall buffers.
is_realm_world()is declared ininclude/linux/arm-rsi-cmds.hwhich only builds on arm64 (it includes <asm/memory.h>), so using it directly in the arch-neutraldrivers/hv/hv_common.cwould break the x86 build. Introduce a Hyper-V-specific helper following the establishedhv_isolation_type_snp()/hv_isolation_type_tdx()pattern.On architectures other than arm64 the weak default keeps the existing behaviour.
Reviewed-by Michael Kelley <[email protected]>Signed-off-by Kameron Carr <[email protected]>--- arch/arm64/hyperv/mshyperv.c | 5 +++++ drivers/hv/hv_common.c | 17 +++++++++++++---- include/asm-generic/mshyperv.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-)arch/arm64/hyperv/mshyperv.c +5
-0@@ -182,3 +182,8 @@ bool hv_is_hyperv_initialized(void)return hyperv_initialized; }EXPORT_SYMBOL_GPL (hv_is_hyperv_initialized); + +bool hv_isolation_type_cca (void ) +{ +return is_realm_world (); +}drivers/hv/hv_common.c +2
-1@@ -476,6 +476,7 @@ int hv_common_cpu_init(unsigned int cpu)u64 msr_vp_index;gfp_t flags;const int pgcount =hv_output_page_exists () ?2 :1 ; +const size_t alloc_size =ALIGN ((size_t )pgcount *HV_HYP_PAGE_SIZE ,PAGE_SIZE );void *mem;int ret =0 ;@@ -489,7 +490,7 @@ int hv_common_cpu_init(unsigned int cpu)* online and then taken offline */ if (!*inputarg) { - mem =kmalloc_array (pgcount,HV_HYP_PAGE_SIZE , flags); + mem =kmalloc (alloc_size, flags);if (!mem)return -ENOMEM ;drivers/hv/hv_common.c int hv_common_cpu_init(unsigned int cpu) · line 504
Quoted 7 lines
drivers/hv/hv_common.c +2
-2@@ -499,14 +500,16 @@ int hv_common_cpu_init(unsigned int cpu) }if (!ms_hyperv.paravisor_present && - (hv_isolation_type_snp () ||hv_isolation_type_tdx ())) { - ret =set_memory_decrypted ((unsigned long )mem, pgcount); + (hv_isolation_type_snp () ||hv_isolation_type_tdx () || +hv_isolation_type_cca ())) {Could this big "if" statement use "
hv_is_isolation_supported()" instead of explicitly testing for each CoCo VM type? I ask partly because Mukesh Rathor has just submitted a patch [1] that introduces a new function that does something almost exactly the same ashv_is_isolation_supported()and uses it here.
Quoted 2 lines
drivers/hv/hv_common.c int hv_common_cpu_init(unsigned int cpu) · line 504
Quoted 2 lines
drivers/hv/hv_common.c +2
-0+ (hv_isolation_type_snp() || hv_isolation_type_tdx() || + hv_isolation_type_cca())) {
With my change, this will become:
(hv_isolation_hw_cvm() || hv_isolation_type_cca())) {Thanks,
-Mukesh
Quoted 49 lines
You don't provide the non-stub
hv_is_isolation_supported()until Patch 6 of this series, but the weak stub should allow everything to build if a bisection splits this patch series.Michael
[1] https://lore.kernel.org/linux-hyperv/[email protected]/
Quoted 41 lines
drivers/hv/hv_common.c +9
-1+ ret =set_memory_decrypted ((unsigned long )mem, + alloc_size >>PAGE_SHIFT );if (ret) {/* It may be unsafe to free 'mem' */ return ret; } -memset (mem,0x00 , pgcount *HV_HYP_PAGE_SIZE ); +memset (mem,0x00 , alloc_size); }/* @@ -666,6 +669,12 @@ bool __weak hv_isolation_type_tdx(void) }EXPORT_SYMBOL_GPL (hv_isolation_type_tdx); +bool __weak hv_isolation_type_cca (void ) +{ +return false; +} +EXPORT_SYMBOL_GPL (hv_isolation_type_cca); +void __weak hv_setup_vmbus_handler (void (*handler)(void )) { }include/asm-generic/mshyperv.h +1
-0@@ -79,6 +79,7 @@ u64 hv_do_fast_hypercall16(u16 control, u64 input1, u64 input2);bool hv_isolation_type_snp (void );bool hv_isolation_type_tdx (void ); +bool hv_isolation_type_cca (void );/* * On architectures where Hyper-V doesn't support AEOI (e.g., ARM64),
--
2.45.4
Re: [PATCH v6 4/6] Drivers: hv: Mark shared memory as decrypted for CCA Realms
Quoted 75 lines · Mukesh R
Quoted 73 lines · Michael Kelley
From: Kameron Carr <[email protected]> Sent: Friday, October 30, 2026 5:14 PM
Quoted 61 lines
In
hv_common_cpu_init(), the per-CPU hypercall input/output pages need to be marked as decrypted (shared) for confidential VM isolation types. This is already done for SNP and TDX isolation; extend the same handling to Arm CCA Realm guests so that the host hypervisor can access the shared hypercall buffers.
is_realm_world()is declared ininclude/linux/arm-rsi-cmds.hwhich only builds on arm64 (it includes <asm/memory.h>), so using it directly in the arch-neutraldrivers/hv/hv_common.cwould break the x86 build. Introduce a Hyper-V-specific helper following the establishedhv_isolation_type_snp()/hv_isolation_type_tdx()pattern.On architectures other than arm64 the weak default keeps the existing behaviour.
Reviewed-by Michael Kelley <[email protected]>Signed-off-by Kameron Carr <[email protected]>---
arch/arm64/hyperv/mshyperv.c | 5 +++++ drivers/hv/hv_common.c | 17 +++++++++++++----include/asm-generic/mshyperv.h| 1 +3 files changed, 19 insertions(+), 4 deletions(-)arch/arm64/hyperv/mshyperv.c +5
-0@@ -182,3 +182,8 @@ bool hv_is_hyperv_initialized(void) return hyperv_initialized; } EXPORT_SYMBOL_GPL(hv_is_hyperv_initialized); + +bool hv_isolation_type_cca (void ) +{ + return is_realm_world(); +}drivers/hv/hv_common.c +2
-1@@ -476,6 +476,7 @@ int hv_common_cpu_init(unsigned int cpu) u64 msr_vp_index; gfp_t flags; const int pgcount = hv_output_page_exists() ? 2 : 1; + const size_t alloc_size = ALIGN((size_t)pgcount * HV_HYP_PAGE_SIZE, PAGE_SIZE); void *mem; int ret = 0;@@ -489,7 +490,7 @@ int hv_common_cpu_init(unsigned int cpu)* online and then taken offline */ if (!*inputarg) { - mem = kmalloc_array(pgcount, HV_HYP_PAGE_SIZE, flags); + mem = kmalloc(alloc_size, flags); if (!mem) return -ENOMEM;@@ -499,14 +500,16 @@ int hv_common_cpu_init(unsigned int cpu) }Quoted 5 lines
if (!ms_hyperv.paravisor_present &&
- (hv_isolation_type_snp()||hv_isolation_type_tdx())) { - ret =set_memory_decrypted((unsigned long)mem, pgcount); + (hv_isolation_type_snp()||hv_isolation_type_tdx()|| +hv_isolation_type_cca())) {Could this big "if" statement use "
hv_is_isolation_supported()" instead of explicitly testing for each CoCo VM type? I ask partly because Mukesh Rathor has just submitted a patch [1] that introduces a new function that does something almost exactly the same ashv_is_isolation_supported()and uses it here.
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
+ (
hv_isolation_type_snp()||hv_isolation_type_tdx()|| +hv_isolation_type_cca())) {With my change, this will become:
(
hv_isolation_hw_cvm()||hv_isolation_type_cca())) {
Any reason you wouldn't change hv_isolation_hw_cvm() to
return hv_isolation_type_snp() || hv_isolation_type_tdx() ||
hv_isolation_type_cca()That would seem more logical to me.
Signature · 2 lines
Regards, Kameron
Quoted 54 lines
Thanks,
-MukeshQuoted 49 lines
You don't provide the non-stub
hv_is_isolation_supported()until Patch 6 of this series, but the weak stub should allow everything to build if a bisection splits this patch series.Michael
[1] https://lore.kernel.org/linux-hyperv/[email protected]/
Quoted 41 lines
+ ret =
set_memory_decrypted((unsigned long)mem, + alloc_size >> PAGE_SHIFT); if (ret) {
/* It may be unsafe to free 'mem' */ return ret;
}-
memset(mem, 0x00, pgcount * HV_HYP_PAGE_SIZE); +memset(mem, 0x00, alloc_size);
}/*
drivers/hv/hv_common.c +6
-0@@ -666,6 +669,12 @@ bool __weak hv_isolation_type_tdx(void) } EXPORT_SYMBOL_GPL(hv_isolation_type_tdx); +bool __weak hv_isolation_type_cca (void ) +{ + return false; +} +EXPORT_SYMBOL_GPL (hv_isolation_type_cca); + void __weak hv_setup_vmbus_handler(void (*handler)(void)) { }include/asm-generic/mshyperv.h +1
-0@@ -79,6 +79,7 @@ u64 hv_do_fast_hypercall16(u16 control, u64 input1, u64 input2); bool hv_isolation_type_snp(void); bool hv_isolation_type_tdx(void); +bool hv_isolation_type_cca (void ); /** On architectures where Hyper-V doesn't support AEOI (e.g., ARM64),
Signature · 1 line
2.45.4
Re: [PATCH v6 4/6] Drivers: hv: Mark shared memory as decrypted for CCA Realms
Quoted 81 lines · Kameron Carr
Quoted 80 lines · Mukesh R
Quoted 62 lines · Michael Kelley
From: Kameron Carr <[email protected]> Sent: Friday, October 30, 2026 5:14 PM
Quoted 61 lines
In
hv_common_cpu_init(), the per-CPU hypercall input/output pages need to be marked as decrypted (shared) for confidential VM isolation types. This is already done for SNP and TDX isolation; extend the same handling to Arm CCA Realm guests so that the host hypervisor can access the shared hypercall buffers.
is_realm_world()is declared ininclude/linux/arm-rsi-cmds.hwhich only builds on arm64 (it includes <asm/memory.h>), so using it directly in the arch-neutraldrivers/hv/hv_common.cwould break the x86 build. Introduce a Hyper-V-specific helper following the establishedhv_isolation_type_snp()/hv_isolation_type_tdx()pattern.On architectures other than arm64 the weak default keeps the existing behaviour.
Reviewed-by Michael Kelley <[email protected]>Signed-off-by Kameron Carr <[email protected]>--- arch/arm64/hyperv/mshyperv.c | 5 +++++ drivers/hv/hv_common.c | 17 +++++++++++++---- include/asm-generic/mshyperv.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-)arch/arm64/hyperv/mshyperv.c +5
-0@@ -182,3 +182,8 @@ bool hv_is_hyperv_initialized(void)return hyperv_initialized; }EXPORT_SYMBOL_GPL (hv_is_hyperv_initialized); + +bool hv_isolation_type_cca (void ) +{ +return is_realm_world (); +}drivers/hv/hv_common.c +2
-1@@ -476,6 +476,7 @@ int hv_common_cpu_init(unsigned int cpu)u64 msr_vp_index;gfp_t flags;const int pgcount =hv_output_page_exists () ?2 :1 ; +const size_t alloc_size =ALIGN ((size_t )pgcount *HV_HYP_PAGE_SIZE ,PAGE_SIZE );void *mem;int ret =0 ;@@ -489,7 +490,7 @@ int hv_common_cpu_init(unsigned int cpu)* online and then taken offline */ if (!*inputarg) { - mem =kmalloc_array (pgcount,HV_HYP_PAGE_SIZE , flags); + mem =kmalloc (alloc_size, flags);if (!mem)return -ENOMEM ;@@ -499,14 +500,16 @@ int hv_common_cpu_init(unsigned int cpu) }Quoted 14 lines
drivers/hv/hv_common.c int hv_common_cpu_init(unsigned int cpu) · line 504
Quoted 5 lines
drivers/hv/hv_common.c +2
-2if (!ms_hyperv.paravisor_present && - (hv_isolation_type_snp () ||hv_isolation_type_tdx ())) { - ret =set_memory_decrypted ((unsigned long )mem, pgcount); + (hv_isolation_type_snp () ||hv_isolation_type_tdx () || +hv_isolation_type_cca ())) {Could this big "if" statement use "
hv_is_isolation_supported()" instead of explicitly testing for each CoCo VM type? I ask partly because Mukesh Rathor has just submitted a patch [1] that introduces a new function that does something almost exactly the same ashv_is_isolation_supported()and uses it here.Quoted 2 lines
drivers/hv/hv_common.c +2
-0+ (hv_isolation_type_snp() || hv_isolation_type_tdx() || + hv_isolation_type_cca())) {With my change, this will become:
Quoted 9 lines
Quoted 1 line
(hv_isolation_hw_cvm() || hv_isolation_type_cca())) {Any reason you wouldn't change
hv_isolation_hw_cvm()toreturn hv_isolation_type_snp() || hv_isolation_type_tdx() || hv_isolation_type_cca()That would seem more logical to me.
We could, I just don't know if on cca, the repeat hypercall has same behavior. I was leaving that for the arm team. Anyways, I sent question to the hyp team, if they say yes, i can update my patch to include that.
Thanks,
-Mukesh
Re: [PATCH v6 4/6] Drivers: hv: Mark shared memory as decrypted for CCA Realms
Quoted 92 lines · Mukesh R
Quoted 81 lines · Kameron Carr
Quoted 80 lines · Mukesh R
Quoted 62 lines · Michael Kelley
From: Kameron Carr <[email protected]> Sent: Friday, October 30, 2026 5:14 PM
Quoted 61 lines
In
hv_common_cpu_init(), the per-CPU hypercall input/output pages need to be marked as decrypted (shared) for confidential VM isolation types. This is already done for SNP and TDX isolation; extend the same handling to Arm CCA Realm guests so that the host hypervisor can access the shared hypercall buffers.
is_realm_world()is declared ininclude/linux/arm-rsi-cmds.hwhich only builds on arm64 (it includes <asm/memory.h>), so using it directly in the arch-neutraldrivers/hv/hv_common.cwould break the x86 build. Introduce a Hyper-V-specific helper following the establishedhv_isolation_type_snp()/hv_isolation_type_tdx()pattern.On architectures other than arm64 the weak default keeps the existing behaviour.
Reviewed-by Michael Kelley <[email protected]>Signed-off-by Kameron Carr <[email protected]>--- arch/arm64/hyperv/mshyperv.c | 5 +++++ drivers/hv/hv_common.c | 17 +++++++++++++---- include/asm-generic/mshyperv.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-)arch/arm64/hyperv/mshyperv.c +5
-0@@ -182,3 +182,8 @@ bool hv_is_hyperv_initialized(void)return hyperv_initialized; }EXPORT_SYMBOL_GPL (hv_is_hyperv_initialized); + +bool hv_isolation_type_cca (void ) +{ +return is_realm_world (); +}drivers/hv/hv_common.c +2
-1@@ -476,6 +476,7 @@ int hv_common_cpu_init(unsigned int cpu)u64 msr_vp_index;gfp_t flags;const int pgcount =hv_output_page_exists () ?2 :1 ; +const size_t alloc_size =ALIGN ((size_t )pgcount *HV_HYP_PAGE_SIZE ,PAGE_SIZE );void *mem;int ret =0 ;@@ -489,7 +490,7 @@ int hv_common_cpu_init(unsigned int cpu)* online and then taken offline */ if (!*inputarg) { - mem =kmalloc_array (pgcount,HV_HYP_PAGE_SIZE , flags); + mem =kmalloc (alloc_size, flags);if (!mem)return -ENOMEM ;@@ -499,14 +500,16 @@ int hv_common_cpu_init(unsigned int cpu) }Quoted 14 lines
drivers/hv/hv_common.c int hv_common_cpu_init(unsigned int cpu) · line 504
Quoted 5 lines
drivers/hv/hv_common.c +2
-2if (!ms_hyperv.paravisor_present && - (hv_isolation_type_snp () ||hv_isolation_type_tdx ())) { - ret =set_memory_decrypted ((unsigned long )mem, pgcount); + (hv_isolation_type_snp () ||hv_isolation_type_tdx () || +hv_isolation_type_cca ())) {Could this big "if" statement use "
hv_is_isolation_supported()" instead of explicitly testing for each CoCo VM type? I ask partly because Mukesh Rathor has just submitted a patch [1] that introduces a new function that does something almost exactly the same ashv_is_isolation_supported()and uses it here.Quoted 2 lines
drivers/hv/hv_common.c +2
-0+ (hv_isolation_type_snp() || hv_isolation_type_tdx() || + hv_isolation_type_cca())) {With my change, this will become:
Quoted 9 lines
Quoted 1 line
(hv_isolation_hw_cvm() || hv_isolation_type_cca())) {Any reason you wouldn't change
hv_isolation_hw_cvm()toreturn hv_isolation_type_snp() || hv_isolation_type_tdx() || hv_isolation_type_cca()That would seem more logical to me.
Quoted 6 lines
We could, I just don't know if on cca, the repeat hypercall has same behavior. I was leaving that for the arm team. Anyways, I sent question to the hyp team, if they say yes, i can update my patch to include that.
Thanks,
-Mukesh
Confirming, arm has same behavior and needs the fix also. So, we can def expand the check to include _cca.
I just sent V1, renaming hv_isolation_hw_cvm() to hv_isolation_type_hw(). If your patch goes after mine, you just need to add to your 0004*:
arch/arm64/hyperv/mshyperv.c +5 -0
@@ -134,3 +134,8 @@ bool hv_is_hyperv_initialized(void)return hyperv_initialized; }EXPORT_SYMBOL_GPL (hv_is_hyperv_initialized); + +bool hv_isolation_type_hw (void ) +{ +return is_realm_world (); +}
OR, you could pick mine 0001-* and make it part of your series, and I can drop it from mine and make it dependent on yours. But mine is small enough that it has higher chances of going in first.....
Thanks,
-Mukesh
Re: [PATCH v6 4/6] Drivers: hv: Mark shared memory as decrypted for CCA Realms
Quoted 122 lines · Mukesh R
Quoted 92 lines · Mukesh R
Quoted 81 lines · Kameron Carr
Quoted 80 lines · Mukesh R
Quoted 62 lines · Michael Kelley
From: Kameron Carr <[email protected]> Sent: Friday, October 30, 2026 5:14 PM
Quoted 61 lines
In
hv_common_cpu_init(), the per-CPU hypercall input/output pages need to be marked as decrypted (shared) for confidential VM isolation types. This is already done for SNP and TDX isolation; extend the same handling to Arm CCA Realm guests so that the host hypervisor can access the shared hypercall buffers.
is_realm_world()is declared ininclude/linux/arm-rsi-cmds.hwhich only builds on arm64 (it includes <asm/memory.h>), so using it directly in the arch-neutraldrivers/hv/hv_common.cwould break the x86 build. Introduce a Hyper-V-specific helper following the establishedhv_isolation_type_snp()/hv_isolation_type_tdx()pattern.On architectures other than arm64 the weak default keeps the existing behaviour.
Reviewed-by Michael Kelley <[email protected]>Signed-off-by Kameron Carr <[email protected]>---
arch/arm64/hyperv/mshyperv.c | 5 +++++ drivers/hv/hv_common.c | 17 +++++++++++++----include/asm-generic/mshyperv.h| 1 +3 files changed, 19 insertions(+), 4 deletions(-)arch/arm64/hyperv/mshyperv.c +5
-0@@ -182,3 +182,8 @@ bool hv_is_hyperv_initialized(void) return hyperv_initialized; } EXPORT_SYMBOL_GPL(hv_is_hyperv_initialized); + +bool hv_isolation_type_cca (void ) +{ + return is_realm_world(); +}drivers/hv/hv_common.c +2
-1@@ -476,6 +476,7 @@ int hv_common_cpu_init(unsigned int cpu) u64 msr_vp_index; gfp_t flags; const int pgcount = hv_output_page_exists() ? 2 : 1; + const size_t alloc_size = ALIGN((size_t)pgcount * HV_HYP_PAGE_SIZE, PAGE_SIZE); void *mem; int ret = 0;@@ -489,7 +490,7 @@ int hv_common_cpu_init(unsigned int cpu)* online and then taken offline */ if (!*inputarg) { - mem = kmalloc_array(pgcount, HV_HYP_PAGE_SIZE, flags); + mem = kmalloc(alloc_size, flags); if (!mem) return -ENOMEM;@@ -499,14 +500,16 @@ int hv_common_cpu_init(unsigned int cpu) }Quoted 14 lines
Quoted 5 lines
if (!ms_hyperv.paravisor_present &&
- (hv_isolation_type_snp()||hv_isolation_type_tdx())) { - ret =set_memory_decrypted((unsigned long)mem, pgcount); + (hv_isolation_type_snp()||hv_isolation_type_tdx()|| +hv_isolation_type_cca())) {Could this big "if" statement use "
hv_is_isolation_supported()" instead of explicitly testing for each CoCo VM type? I ask partly because Mukesh Rathor has just submitted a patch [1] that introduces a new function that does something almost exactly the same ashv_is_isolation_supported()and uses it here.Quoted 2 lines
+ (
hv_isolation_type_snp()||hv_isolation_type_tdx()|| +hv_isolation_type_cca())) {With my change, this will become:
Quoted 9 lines
Quoted 1 line
(
hv_isolation_hw_cvm()||hv_isolation_type_cca())) {Any reason you wouldn't change
hv_isolation_hw_cvm()toreturn
hv_isolation_type_snp()||hv_isolation_type_tdx()||hv_isolation_type_cca()That would seem more logical to me.
Quoted 6 lines
We could, I just don't know if on cca, the repeat hypercall has same behavior. I was leaving that for the arm team. Anyways, I sent question to the hyp team, if they say yes, i can update my patch to include that.
Thanks,
-MukeshConfirming, arm has same behavior and needs the fix also. So, we can def expand the check to include
_cca.I just sent V1, renaming
hv_isolation_hw_cvm()tohv_isolation_type_hw(). If your patch goes after mine, you just need to add to your 0004*:arch/arm64/hyperv/mshyperv.c +5
-0@@ -134,3 +134,8 @@ bool hv_is_hyperv_initialized(void) return hyperv_initialized; } EXPORT_SYMBOL_GPL(hv_is_hyperv_initialized); + +bool hv_isolation_type_hw (void ) +{ + return is_realm_world(); +}
Quoted 4 lines
OR, you could pick mine 0001-* and make it part of your series, and I can drop it from mine and make it dependent on yours. But mine is small enough that it has higher chances of going in first.....
This patch set has already been applied to hyperv-next, so maybe you can rebase off that.
Signature · 2 lines
Regards, Kameron
Re: [PATCH v6 4/6] Drivers: hv: Mark shared memory as decrypted for CCA Realms
Quoted 123 lines · Kameron Carr
Quoted 122 lines · Mukesh R
Quoted 92 lines · Mukesh R
Quoted 81 lines · Kameron Carr
Quoted 80 lines · Mukesh R
Quoted 62 lines · Michael Kelley
From: Kameron Carr <[email protected]> Sent: Friday, October 30, 2026 5:14 PM
Quoted 61 lines
In
hv_common_cpu_init(), the per-CPU hypercall input/output pages need to be marked as decrypted (shared) for confidential VM isolation types. This is already done for SNP and TDX isolation; extend the same handling to Arm CCA Realm guests so that the host hypervisor can access the shared hypercall buffers.
is_realm_world()is declared ininclude/linux/arm-rsi-cmds.hwhich only builds on arm64 (it includes <asm/memory.h>), so using it directly in the arch-neutraldrivers/hv/hv_common.cwould break the x86 build. Introduce a Hyper-V-specific helper following the establishedhv_isolation_type_snp()/hv_isolation_type_tdx()pattern.On architectures other than arm64 the weak default keeps the existing behaviour.
Reviewed-by Michael Kelley <[email protected]>Signed-off-by Kameron Carr <[email protected]>--- arch/arm64/hyperv/mshyperv.c | 5 +++++ drivers/hv/hv_common.c | 17 +++++++++++++---- include/asm-generic/mshyperv.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-)arch/arm64/hyperv/mshyperv.c +5
-0@@ -182,3 +182,8 @@ bool hv_is_hyperv_initialized(void)return hyperv_initialized; }EXPORT_SYMBOL_GPL (hv_is_hyperv_initialized); + +bool hv_isolation_type_cca (void ) +{ +return is_realm_world (); +}drivers/hv/hv_common.c +2
-1@@ -476,6 +476,7 @@ int hv_common_cpu_init(unsigned int cpu)u64 msr_vp_index;gfp_t flags;const int pgcount =hv_output_page_exists () ?2 :1 ; +const size_t alloc_size =ALIGN ((size_t )pgcount *HV_HYP_PAGE_SIZE ,PAGE_SIZE );void *mem;int ret =0 ;@@ -489,7 +490,7 @@ int hv_common_cpu_init(unsigned int cpu)* online and then taken offline */ if (!*inputarg) { - mem =kmalloc_array (pgcount,HV_HYP_PAGE_SIZE , flags); + mem =kmalloc (alloc_size, flags);if (!mem)return -ENOMEM ;@@ -499,14 +500,16 @@ int hv_common_cpu_init(unsigned int cpu) }Quoted 14 lines
drivers/hv/hv_common.c int hv_common_cpu_init(unsigned int cpu) · line 504
Quoted 5 lines
drivers/hv/hv_common.c +2
-2if (!ms_hyperv.paravisor_present && - (hv_isolation_type_snp () ||hv_isolation_type_tdx ())) { - ret =set_memory_decrypted ((unsigned long )mem, pgcount); + (hv_isolation_type_snp () ||hv_isolation_type_tdx () || +hv_isolation_type_cca ())) {Could this big "if" statement use "
hv_is_isolation_supported()" instead of explicitly testing for each CoCo VM type? I ask partly because Mukesh Rathor has just submitted a patch [1] that introduces a new function that does something almost exactly the same ashv_is_isolation_supported()and uses it here.Quoted 2 lines
drivers/hv/hv_common.c +2
-0+ (hv_isolation_type_snp() || hv_isolation_type_tdx() || + hv_isolation_type_cca())) {With my change, this will become:
Quoted 9 lines
Quoted 1 line
(hv_isolation_hw_cvm() || hv_isolation_type_cca())) {Any reason you wouldn't change
hv_isolation_hw_cvm()toreturn hv_isolation_type_snp() || hv_isolation_type_tdx() || hv_isolation_type_cca()That would seem more logical to me.
Quoted 6 lines
We could, I just don't know if on cca, the repeat hypercall has same behavior. I was leaving that for the arm team. Anyways, I sent question to the hyp team, if they say yes, i can update my patch to include that.
Thanks,
-MukeshConfirming, arm has same behavior and needs the fix also. So, we can def expand the check to include
_cca.I just sent V1, renaming
hv_isolation_hw_cvm()tohv_isolation_type_hw(). If your patch goes after mine, you just need to add to your 0004*:arch/arm64/hyperv/mshyperv.c +5
-0@@ -134,3 +134,8 @@ bool hv_is_hyperv_initialized(void)return hyperv_initialized; }EXPORT_SYMBOL_GPL (hv_is_hyperv_initialized); + +bool hv_isolation_type_hw (void ) +{ +return is_realm_world (); +}
Quoted 8 lines
Quoted 4 lines
OR, you could pick mine 0001-* and make it part of your series, and I can drop it from mine and make it dependent on yours. But mine is small enough that it has higher chances of going in first.....
This patch set has already been applied to hyperv-next, so maybe you can rebase off that.
Ok, I'll rebase my patches from hyperv-fixes to hyperv-next, and resubmit.
Thanks,
-Mukesh
Re: [PATCH v6 4/6] Drivers: hv: Mark shared memory as decrypted for CCA Realms
Quoted 133 lines · Mukesh R
Quoted 123 lines · Kameron Carr
Quoted 122 lines · Mukesh R
Quoted 92 lines · Mukesh R
Quoted 81 lines · Kameron Carr
Quoted 80 lines · Mukesh R
Quoted 62 lines · Michael Kelley
From: Kameron Carr <[email protected]> Sent: Friday, October 30, 2026 5:14 PM
Quoted 61 lines
In
hv_common_cpu_init(), the per-CPU hypercall input/output pages need to be marked as decrypted (shared) for confidential VM isolation types. This is already done for SNP and TDX isolation; extend the same handling to Arm CCA Realm guests so that the host hypervisor can access the shared hypercall buffers.
is_realm_world()is declared ininclude/linux/arm-rsi-cmds.hwhich only builds on arm64 (it includes <asm/memory.h>), so using it directly in the arch-neutraldrivers/hv/hv_common.cwould break the x86 build. Introduce a Hyper-V-specific helper following the establishedhv_isolation_type_snp()/hv_isolation_type_tdx()pattern.On architectures other than arm64 the weak default keeps the existing behaviour.
Reviewed-by Michael Kelley <[email protected]>Signed-off-by Kameron Carr <[email protected]>---
arch/arm64/hyperv/mshyperv.c | 5 +++++ drivers/hv/hv_common.c | 17 +++++++++++++----include/asm-generic/mshyperv.h| 1 +3 files changed, 19 insertions(+), 4 deletions(-)arch/arm64/hyperv/mshyperv.c +5
-0@@ -182,3 +182,8 @@ bool hv_is_hyperv_initialized(void) return hyperv_initialized; } EXPORT_SYMBOL_GPL(hv_is_hyperv_initialized); + +bool hv_isolation_type_cca (void ) +{ + return is_realm_world(); +}drivers/hv/hv_common.c +2
-1@@ -476,6 +476,7 @@ int hv_common_cpu_init(unsigned int cpu) u64 msr_vp_index; gfp_t flags; const int pgcount = hv_output_page_exists() ? 2 : 1; + const size_t alloc_size = ALIGN((size_t)pgcount * HV_HYP_PAGE_SIZE, PAGE_SIZE); void *mem; int ret = 0;@@ -489,7 +490,7 @@ int hv_common_cpu_init(unsigned int cpu)* online and then taken offline */ if (!*inputarg) { - mem = kmalloc_array(pgcount, HV_HYP_PAGE_SIZE, flags); + mem = kmalloc(alloc_size, flags); if (!mem) return -ENOMEM;@@ -499,14 +500,16 @@ int hv_common_cpu_init(unsigned int cpu) }Quoted 14 lines
Quoted 5 lines
if (!ms_hyperv.paravisor_present &&
- (hv_isolation_type_snp()||hv_isolation_type_tdx())) { - ret =set_memory_decrypted((unsigned long)mem, pgcount); + (hv_isolation_type_snp()||hv_isolation_type_tdx()|| +hv_isolation_type_cca())) {Could this big "if" statement use "
hv_is_isolation_supported()" instead of explicitly testing for each CoCo VM type? I ask partly because Mukesh Rathor has just submitted a patch [1] that introduces a new function that does something almost exactly the same ashv_is_isolation_supported()and uses it here.Quoted 2 lines
+ (
hv_isolation_type_snp()||hv_isolation_type_tdx()|| +hv_isolation_type_cca())) {With my change, this will become:
Quoted 9 lines
Quoted 1 line
(
hv_isolation_hw_cvm()||hv_isolation_type_cca())) {Any reason you wouldn't change
hv_isolation_hw_cvm()toreturn
hv_isolation_type_snp()||hv_isolation_type_tdx()||hv_isolation_type_cca()That would seem more logical to me.
Quoted 6 lines
We could, I just don't know if on cca, the repeat hypercall has same behavior. I was leaving that for the arm team. Anyways, I sent question to the hyp team, if they say yes, i can update my patch to include that.
Thanks,
-MukeshConfirming, arm has same behavior and needs the fix also. So, we can def expand the check to include
_cca.I just sent V1, renaming
hv_isolation_hw_cvm()tohv_isolation_type_hw(). If your patch goes after mine, you just need to add to your 0004*:arch/arm64/hyperv/mshyperv.c +5
-0@@ -134,3 +134,8 @@ bool hv_is_hyperv_initialized(void) return hyperv_initialized; } EXPORT_SYMBOL_GPL(hv_is_hyperv_initialized); + +bool hv_isolation_type_hw (void ) +{ + return is_realm_world(); +}Quoted 8 lines
Quoted 4 lines
OR, you could pick mine 0001-* and make it part of your series, and I can drop it from mine and make it dependent on yours. But mine is small enough that it has higher chances of going in first.....
This patch set has already been applied to hyperv-next, so maybe you can rebase off that.
Quoted 6 lines
Ok, I'll rebase my patches from hyperv-fixes to hyperv-next, and resubmit.
Thanks,
-Mukesh
On second thought, given these are overloaded functions, adding a new function makes it complicated. Since it's only two places, it's just not worth it. Punting on it for now...
Thanks,
-Mukesh
Re: [PATCH v6 4/6] Drivers: hv: Mark shared memory as decrypted for CCA Realms
In reply to Kameron CarrQuoted 27 lines · Kameron Carr
Quoted 26 lines · Mukesh R
Quoted 25 lines · Michael Kelley
From: Kameron Carr <[email protected]> Sent: Friday, October 30, 2026 5:14 PM
Quoted 24 lines
In
hv_common_cpu_init(), the per-CPU hypercall input/output pages need to be marked as decrypted (shared) for confidential VM isolation types. This is already done for SNP and TDX isolation; extend the same handling to Arm CCA Realm guests so that the host hypervisor can access the shared hypercall buffers.
is_realm_world()is declared ininclude/linux/arm-rsi-cmds.hwhich only builds on arm64 (it includes <asm/memory.h>), so using it directly in the arch-neutraldrivers/hv/hv_common.cwould break the x86 build. Introduce a Hyper-V-specific helper following the establishedhv_isolation_type_snp()/hv_isolation_type_tdx()pattern.On architectures other than arm64 the weak default keeps the existing behaviour.
Reviewed-by Michael Kelley <[email protected]>Signed-off-by Kameron Carr <[email protected]>--- arch/arm64/hyperv/mshyperv.c | 5 +++++ drivers/hv/hv_common.c | 17 +++++++++++++---- include/asm-generic/mshyperv.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-)
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
arch/arm64/hyperv/mshyperv.c +0
-0@@ -182,3 +182,8 @@ bool hv_is_hyperv_initialized(void)Quoted 8 lines
Quoted 8 lines
arch/arm64/hyperv/mshyperv.c bool hv_is_hyperv_initialized(void) · line 189
Quoted 8 lines
arch/arm64/hyperv/mshyperv.c +5
-0return hyperv_initialized; }EXPORT_SYMBOL_GPL (hv_is_hyperv_initialized); + +bool hv_isolation_type_cca (void ) +{ +return is_realm_world (); +}
Hey Kameron,
Since this function is added to check cca and is being used now, there are places that still use is_realm_world() in arch/arm64/hyperv/mshyperv.c that I think should switch over to hv_isolation_type_cca(). Should be quick patch.
Thanks,
-Mukesh
Quoted 50 lines
Quoted 36 lines
Quoted 35 lines
Quoted 22 lines
drivers/hv/hv_common.c +2
-1@@ -476,6 +476,7 @@ int hv_common_cpu_init(unsigned int cpu)u64 msr_vp_index;gfp_t flags;const int pgcount =hv_output_page_exists () ?2 :1 ; +const size_t alloc_size =ALIGN ((size_t )pgcount *HV_HYP_PAGE_SIZE ,PAGE_SIZE );void *mem;int ret =0 ;@@ -489,7 +490,7 @@ int hv_common_cpu_init(unsigned int cpu)* online and then taken offline */ if (!*inputarg) { - mem =kmalloc_array (pgcount,HV_HYP_PAGE_SIZE , flags); + mem =kmalloc (alloc_size, flags);if (!mem)return -ENOMEM ;drivers/hv/hv_common.c int hv_common_cpu_init(unsigned int cpu) · line 504
Quoted 7 lines
drivers/hv/hv_common.c +2
-2@@ -499,14 +500,16 @@ int hv_common_cpu_init(unsigned int cpu) }if (!ms_hyperv.paravisor_present && - (hv_isolation_type_snp () ||hv_isolation_type_tdx ())) { - ret =set_memory_decrypted ((unsigned long )mem, pgcount); + (hv_isolation_type_snp () ||hv_isolation_type_tdx () || +hv_isolation_type_cca ())) {Could this big "if" statement use "
hv_is_isolation_supported()" instead of explicitly testing for each CoCo VM type? I ask partly because Mukesh Rathor has just submitted a patch [1] that introduces a new function that does something almost exactly the same ashv_is_isolation_supported()and uses it here.Quoted 6 lines
Quoted 2 lines
drivers/hv/hv_common.c int hv_common_cpu_init(unsigned int cpu) · line 504
Quoted 2 lines
drivers/hv/hv_common.c +2
-0+ (hv_isolation_type_snp() || hv_isolation_type_tdx() || + hv_isolation_type_cca())) {With my change, this will become:
(hv_isolation_hw_cvm() || hv_isolation_type_cca())) {Any reason you wouldn't change
hv_isolation_hw_cvm()toreturn hv_isolation_type_snp() || hv_isolation_type_tdx() || hv_isolation_type_cca()That would seem more logical to me.
PATCH v6 5/6 arm64: hyperv: Route hypercalls through RSI host call in CCA Realms
In reply to Kameron CarrModify the five hypercall wrapper functions to check is_realm_world() and use the per-CPU rsi_host_call structure when inside a Realm.
--- arch/arm64/hyperv/hv_core.c | 155 ++++++++++++++++++++++++++++-------- 1 file changed, 121 insertions(+), 34 deletions(-)
arch/arm64/hyperv/hv_core.c +121 -34
@@ -12,11 +12,43 @@#include <linux/export.h> #include <linux/mm.h> #include <linux/arm-smccc.h> +#include <linux/arm-rsi-cmds.h> #include <linux/module.h> +#include <linux/smp.h> #include <asm-generic/bug.h> #include <hyperv/hvhdk.h> #include <asm/mshyperv.h> +/* +* hv_do_rsi_hypercall - Helper function to invoke a hypercall from a +* Realm world using the RSI interface. +*/ +static u64 hv_do_rsi_hypercall (u64 control,u64 input1,u64 input2) +{ +struct rsi_host_call *hostcall; +unsigned long flags; +u64 ret; + +if (!hv_hostcall_array) +return HV_STATUS_INVALID_HYPERCALL_INPUT ; + +local_irq_save (flags); + hostcall = &hv_hostcall_array[smp_processor_id ()]; +memset (hostcall,0 ,sizeof (*hostcall)); + hostcall->gprs[0 ] =HV_FUNC_ID ; + hostcall->gprs[1 ] = control; + hostcall->gprs[2 ] = input1; + hostcall->gprs[3 ] = input2; + +if (rsi_host_call (virt_to_phys (hostcall)) ==RSI_SUCCESS ) + ret = hostcall->gprs[0 ]; +else + ret =HV_STATUS_INVALID_HYPERCALL_INPUT ; + +local_irq_restore (flags); +return ret; +} +/* * hv_do_hypercall- Invoke the specified hypercall */
@@ -29,8 +61,11 @@ u64 hv_do_hypercall(u64 control, void *input, void *output) input_address = input ?virt_to_phys (input) :0 ; output_address = output ?virt_to_phys (output) :0 ; -arm_smccc_1_1_hvc (HV_FUNC_ID , control, - input_address, output_address, &res); +if (is_realm_world ()) +return hv_do_rsi_hypercall (control, input_address, output_address); + +arm_smccc_1_1_hvc (HV_FUNC_ID , control, input_address, + output_address, &res);return res.a0; }EXPORT_SYMBOL_GPL (hv_do_hypercall);
@@ -48,6 +83,9 @@ u64 hv_do_fast_hypercall8(u16 code, u64 input) control = (u64 )code |HV_HYPERCALL_FAST_BIT ; +if (is_realm_world ()) +return hv_do_rsi_hypercall (control, input,0 ); +arm_smccc_1_1_hvc (HV_FUNC_ID , control, input, &res);return res.a0; }
@@ -65,6 +103,9 @@ u64 hv_do_fast_hypercall16(u16 code, u64 input1, u64 input2) control = (u64 )code |HV_HYPERCALL_FAST_BIT ; +if (is_realm_world ()) +return hv_do_rsi_hypercall (control, input1, input2); +arm_smccc_1_1_hvc (HV_FUNC_ID , control, input1, input2, &res);return res.a0; }
@@ -76,24 +117,44 @@ EXPORT_SYMBOL_GPL(hv_do_fast_hypercall16);void hv_set_vpreg (u32 msr,u64 value) {struct arm_smccc_res res; +struct rsi_host_call *hostcall; +unsigned long flags; +u64 status; -arm_smccc_1_1_hvc (HV_FUNC_ID , -HVCALL_SET_VP_REGISTERS |HV_HYPERCALL_FAST_BIT | -HV_HYPERCALL_REP_COMP_1 , -HV_PARTITION_ID_SELF , -HV_VP_INDEX_SELF , - msr, -0 , - value, -0 , - &res); +if (is_realm_world ()) { +local_irq_save (flags); + hostcall = &hv_hostcall_array[smp_processor_id ()]; +memset (hostcall,0 ,sizeof (*hostcall)); + hostcall->gprs[0 ] =HV_FUNC_ID ; + hostcall->gprs[1 ] =HVCALL_SET_VP_REGISTERS | +HV_HYPERCALL_FAST_BIT | +HV_HYPERCALL_REP_COMP_1 ; + hostcall->gprs[2 ] =HV_PARTITION_ID_SELF ; + hostcall->gprs[3 ] =HV_VP_INDEX_SELF ; + hostcall->gprs[4 ] = msr; + hostcall->gprs[6 ] = value; + +if (rsi_host_call (virt_to_phys (hostcall)) ==RSI_SUCCESS ) + status = hostcall->gprs[0 ]; +else + status =HV_STATUS_INVALID_HYPERCALL_INPUT ; +local_irq_restore (flags); + }else { +arm_smccc_1_1_hvc (HV_FUNC_ID , +HVCALL_SET_VP_REGISTERS | +HV_HYPERCALL_FAST_BIT | +HV_HYPERCALL_REP_COMP_1 , +HV_PARTITION_ID_SELF ,HV_VP_INDEX_SELF , msr, +0 , value,0 , &res); + status = res.a0; + }/* -* Something is fundamentally broken in the hypervisor if -* setting a VP register fails. There's really no way to -* continue as a guest VM, so panic. +* Something is fundamentally broken in the hypervisor (or, in a +* Realm, the RMM denied the host call) if setting a VP register +* fails. There's really no way to continue as a guest VM, so panic. */ -BUG_ON (!hv_result_success (res.a0)); +BUG_ON (!hv_result_success (status)); }EXPORT_SYMBOL_GPL (hv_set_vpreg);
@@ -108,29 +169,55 @@ void hv_get_vpreg_128(u32 msr, struct hv_get_vp_registers_output *result) {struct arm_smccc_1_2_regs args;struct arm_smccc_1_2_regs res; +struct rsi_host_call *hostcall; +unsigned long flags; +u64 status; - args.a0 =HV_FUNC_ID ; - args.a1 =HVCALL_GET_VP_REGISTERS |HV_HYPERCALL_FAST_BIT | -HV_HYPERCALL_REP_COMP_1 ; - args.a2 =HV_PARTITION_ID_SELF ; - args.a3 =HV_VP_INDEX_SELF ; - args.a4 = msr; +if (is_realm_world ()) { +local_irq_save (flags); + hostcall = &hv_hostcall_array[smp_processor_id ()]; +memset (hostcall,0 ,sizeof (*hostcall)); -/* -* Use the SMCCC 1.2 interface because the results are in registers -* beyond X0-X3. -*/ -arm_smccc_1_2_hvc (&args, &res); + hostcall->gprs[0 ] =HV_FUNC_ID ; + hostcall->gprs[1 ] =HVCALL_GET_VP_REGISTERS | +HV_HYPERCALL_FAST_BIT | +HV_HYPERCALL_REP_COMP_1 ; + hostcall->gprs[2 ] =HV_PARTITION_ID_SELF ; + hostcall->gprs[3 ] =HV_VP_INDEX_SELF ; + hostcall->gprs[4 ] = msr; + +if (rsi_host_call (virt_to_phys (hostcall)) ==RSI_SUCCESS ) { + status = hostcall->gprs[0 ]; + result->as64.low = hostcall->gprs[6 ]; + result->as64.high = hostcall->gprs[7 ]; + }else { + status =HV_STATUS_INVALID_HYPERCALL_INPUT ; + } +local_irq_restore (flags); + }else { + args.a0 =HV_FUNC_ID ; + args.a1 =HVCALL_GET_VP_REGISTERS |HV_HYPERCALL_FAST_BIT | +HV_HYPERCALL_REP_COMP_1 ; + args.a2 =HV_PARTITION_ID_SELF ; + args.a3 =HV_VP_INDEX_SELF ; + args.a4 = msr; + +/* +* Use the SMCCC 1.2 interface because the results are in +* registers beyond X0-X3. +*/ +arm_smccc_1_2_hvc (&args, &res); + status = res.a0; + result->as64.low = res.a6; + result->as64.high = res.a7; + }/* -* Something is fundamentally broken in the hypervisor if -* getting a VP register fails. There's really no way to -* continue as a guest VM, so panic. +* Something is fundamentally broken in the hypervisor (or, in a +* Realm, the RMM denied the host call) if getting a VP register +* fails. There's really no way to continue as a guest VM, so panic. */ -BUG_ON (!hv_result_success (res.a0)); - - result->as64.low = res.a6; - result->as64.high = res.a7; +BUG_ON (!hv_result_success (status)); }EXPORT_SYMBOL_GPL (hv_get_vpreg_128);
Signature · 1 line
2.45.4
PATCH v6 6/6 arm64: hyperv: Implement hv_is_isolation_supported() for CCA Realms
In reply to Kameron CarrProvide an arm64 implementation of hv_is_isolation_supported() that overrides the __weak default in drivers/hv/hv_common.c.
The implementation deliberately does not depend on hv_is_hyperv_initialized() because hv_common_init() consults hv_is_isolation_supported() before hyperv_initialized is set.
--- arch/arm64/hyperv/mshyperv.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/hyperv/mshyperv.c +5 -0
@@ -187,3 +187,8 @@ bool hv_isolation_type_cca(void) {return is_realm_world (); } + +bool hv_is_isolation_supported (void ) +{ +return is_realm_world (); +}
Signature · 1 line
2.45.4
RE: [PATCH v6 6/6] arm64: hyperv: Implement hv_is_isolation_supported() for CCA Realms
From: Kameron Carr <[email protected]> Sent: Friday, October 30, 2026 5:14 PM
Quoted 7 lines
Provide an arm64 implementation of
hv_is_isolation_supported()that overrides the__weakdefault indrivers/hv/hv_common.c.The implementation deliberately does not depend on
hv_is_hyperv_initialized()becausehv_common_init()consultshv_is_isolation_supported()beforehyperv_initializedis set.
Quibble: What's the genesis of this statement about hv_is_hyperv_initialized()? On the x86 side, hv_is_isolation_supported() doesn't depend on hv_is_hyperv_initialized(), so I don't think you are making a distinction vs. what x86 does. The statement seems like it might be a leftover from an early version of this patch set.
Michael
Quoted 23 lines
Reviewed-by Michael Kelley <[email protected]>Signed-off-by Kameron Carr <[email protected]>--- arch/arm64/hyperv/mshyperv.c | 5 +++++ 1 file changed, 5 insertions(+)arch/arm64/hyperv/mshyperv.c +5
-1@@ -187,3 +187,8 @@ bool hv_isolation_type_cca(void) {return is_realm_world (); } + +bool hv_is_isolation_supported (void ) +{ +return is_realm_world (); +} --2.45.4
Re: [PATCH v6 6/6] arm64: hyperv: Implement hv_is_isolation_supported() for CCA Realms
Quoted 9 lines · Michael Kelley
From: Kameron Carr <[email protected]> Sent: Friday, October 30, 2026 5:14 PM
Quoted 7 lines
Provide an arm64 implementation of
hv_is_isolation_supported()that overrides the__weakdefault indrivers/hv/hv_common.c.The implementation deliberately does not depend on
hv_is_hyperv_initialized()becausehv_common_init()consultshv_is_isolation_supported()beforehyperv_initializedis set.
Quoted 5 lines
Quibble: What's the genesis of this statement about
hv_is_hyperv_initialized()? On the x86 side,hv_is_isolation_supported()doesn't depend onhv_is_hyperv_initialized(), so I don't think you are making a distinction vs. what x86 does. The statement seems like it might be a leftover from an early version of this patch set.
From what I recall, I wrote this line after going down a long rabbit hole attempting to have functional parity with x86 hv_is_isolation_supported(). I agree that is doesn't make sense without context.
I couldn't find equivalent methods for checking if the Realm is running on Hyper-V. I initially considered using hv_is_hyperv_initialized(), but that ran into ordering issue described above. I eventually concluded that just returning is_realm_world() is sufficient, since hv_is_isolation_supported() is never used to determine whether the VM is running on Hyper-V.
The comment would be more clear if it simply pointed out that hv_is_isolation_supported() functionally differs on ARM64 vs. x86 because it does not check whether it is running on Hyper-V.
I believe Wei already applied this series to hyperv-next, but perhaps he can remove this line from the commit message.
Signature · 2 lines
Regards, Kameron
Quoted 25 lines
Michael
Quoted 23 lines
Reviewed-by Michael Kelley <[email protected]>Signed-off-by Kameron Carr <[email protected]>--- arch/arm64/hyperv/mshyperv.c | 5 +++++ 1 file changed, 5 insertions(+)arch/arm64/hyperv/mshyperv.c +5
-1@@ -187,3 +187,8 @@ bool hv_isolation_type_cca(void) {return is_realm_world (); } + +bool hv_is_isolation_supported (void ) +{ +return is_realm_world (); +} --2.45.4