[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [PATCH v4 5/6] xen/mem_access: wrap memory access when VM_EVENT=n


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Tamas K Lengyel <tamas@xxxxxxxxxxxxx>
  • From: "Penny, Zheng" <penny.zheng@xxxxxxx>
  • Date: Fri, 16 Jan 2026 07:44:37 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=O0qMULjR5iUcnvMlfl+mMRmygHqA3d8qIBtZu1FHGgg=; b=xRYW1N0qBdLfnKgtxYMeS/iNF7Q+sAZk+qQ/4Obv886pMeZpvo5w8h2UwZqNvJ0qi6dtzXgHUUDFKnCq6NMXGCIiieuCTAtVDoORFDx3hRVInEKQvpFt1x4D9ui5n3bSAlnBotDG0/iQXB33H6mXIlloCS2zgvf12ocPAcbYeyTvVBgthJojhB0TixZWJd6DLTLq0WnVcmxbG3y1GtN6Lsgd1MOLyshZHHTqNe3MgxmWYtXI9PE9DW+6NJk0caWzI0bpapz3MLOgTxLVtgGXHaCifdZW5yZmmCXm30ed/Ys1F49W0J5Rz95KQ/6gn0B6nyt7MwFN4itdHasBUK1ySg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f3QCkdot+IMRDqd5PQhJUq7IIOMDQ/Vd68CzeQoeXoWjibOuxnZMsyxL7yzYbrp6r8gi6bIv8OJK9PEQTKtGS3sd0b/BXDSzSqS+taYUznfi4LwNnbxQQRVAPuAgScnwcJAdjTTWGxweEF1RfRes3w9HcTsEwsFE0RGrzVbJy2ADkPxPvM7nsLGD9a4cEn1aNY90v4AKGJLIieHAeQJnfJ4oP8KTRrio/p3mye7R/uPKLS/owwzzC4OYU6ZUEWm66xYBALzkqBCc02jNfi5Dj8g9BeJKmEpuapXCduR1t+692Pm3O3TQgUye+Y3D5Sxud20UbDvodZBgOa2BqLbSvQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Delivery-date: Fri, 16 Jan 2026 07:44:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Msip_labels: MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_Enabled=True;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_SetDate=2026-01-16T07:44:24.0000000Z;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_Name=Open Source;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_ContentBits=3;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_Method=Privileged
  • Thread-index: AQHchgFz7GhZy9MFSkqKuUrhU5ZbzrVUa57Q
  • Thread-topic: [PATCH v4 5/6] xen/mem_access: wrap memory access when VM_EVENT=n

[Public]

Hi, Tamas

May I ask a review on this commit?

Many thanks,
Penny Zheng

> -----Original Message-----
> From: Penny, Zheng <penny.zheng@xxxxxxx>
> Sent: Thursday, January 15, 2026 5:29 PM
> To: xen-devel@xxxxxxxxxxxxxxxxxxxx; Andryuk, Jason <Jason.Andryuk@xxxxxxx>
> Cc: Huang, Ray <Ray.Huang@xxxxxxx>; Penny, Zheng
> <penny.zheng@xxxxxxx>; Jan Beulich <jbeulich@xxxxxxxx>; Andrew Cooper
> <andrew.cooper3@xxxxxxxxxx>; Roger Pau Monné <roger.pau@xxxxxxxxxx>; Tamas
> K Lengyel <tamas@xxxxxxxxxxxxx>; Alexandru Isaila <aisaila@xxxxxxxxxxxxxxx>;
> Petre Pircalabu <ppircalabu@xxxxxxxxxxxxxxx>
> Subject: [PATCH v4 5/6] xen/mem_access: wrap memory access when
> VM_EVENT=n
>
> Feature memory access is based on vm event subsystem, and it could be disabled
> in the future. So a few switch-blocks in do_altp2m_op() need
> vm_event_is_enabled() condition check to pass compilation when ALTP2M=y and
> VM_EVENT=n(, hence MEM_ACCESS=n), like
> HVMOP_altp2m_set_mem_access, etc.
> Function p2m_mem_access_check() still needs stub when VM_EVENT=n to pass
> compilation.
> Although local variable "req_ptr" still remains NULL throughout its lifetime, 
> with the
> change of NULL assignment, we will face runtime undefined error only when
> CONFIG_USBAN is on. So we strengthen the condition check via adding
> vm_event_is_enabled() for the special case.
>
> Signed-off-by: Penny Zheng <Penny.Zheng@xxxxxxx>
> Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
> ---
> v1 -> v3:
> - a comment next to the excessive condition
> - use vm_event_is_enabled() instead
> - avoid heavy churn by using the inverted condition plus break
> ---
> v3 - v4:
> - refine comment
> ---
>  xen/arch/x86/hvm/hvm.c                | 26 +++++++++++++++++++++++++-
>  xen/arch/x86/include/asm/mem_access.h | 10 ++++++++++
>  2 files changed, 35 insertions(+), 1 deletion(-)
>
> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index
> 07e54890d9..b34cd29629 100644
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -52,6 +52,7 @@
>  #include <asm/i387.h>
>  #include <asm/mc146818rtc.h>
>  #include <asm/mce.h>
> +#include <asm/mem_access.h>
>  #include <asm/monitor.h>
>  #include <asm/msr.h>
>  #include <asm/mtrr.h>
> @@ -2082,7 +2083,12 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned
> long gla,  #endif
>      }
>
> -    if ( req_ptr )
> +    /*
> +     * req_ptr being constant NULL when !CONFIG_VM_EVENT,
> CONFIG_UBSAN=y
> +     * builds have been observed to still hit undefined-ness at runtime.
> +     * Hence do a seemingly redundant vm_event_is_enabled() check here.
> +     */
> +    if ( req_ptr && vm_event_is_enabled(curr) )
>      {
>          if ( monitor_traps(curr, sync, req_ptr) < 0 )
>              rc = 0;
> @@ -4804,6 +4810,12 @@ static int do_altp2m_op(
>          break;
>
>      case HVMOP_altp2m_set_mem_access:
> +        if ( !vm_event_is_enabled(current) )
> +        {
> +            rc = -EOPNOTSUPP;
> +            break;
> +        }
> +
>          if ( a.u.mem_access.pad )
>              rc = -EINVAL;
>          else
> @@ -4813,6 +4825,12 @@ static int do_altp2m_op(
>          break;
>
>      case HVMOP_altp2m_set_mem_access_multi:
> +        if ( !vm_event_is_enabled(current) )
> +        {
> +            rc = -EOPNOTSUPP;
> +            break;
> +        }
> +
>          if ( a.u.set_mem_access_multi.pad ||
>               a.u.set_mem_access_multi.opaque > a.u.set_mem_access_multi.nr )
>          {
> @@ -4844,6 +4862,12 @@ static int do_altp2m_op(
>          break;
>
>      case HVMOP_altp2m_get_mem_access:
> +        if ( !vm_event_is_enabled(current) )
> +        {
> +            rc = -EOPNOTSUPP;
> +            break;
> +        }
> +
>          if ( a.u.mem_access.pad )
>              rc = -EINVAL;
>          else
> diff --git a/xen/arch/x86/include/asm/mem_access.h
> b/xen/arch/x86/include/asm/mem_access.h
> index 257ed33de1..790bed81e8 100644
> --- a/xen/arch/x86/include/asm/mem_access.h
> +++ b/xen/arch/x86/include/asm/mem_access.h
> @@ -14,6 +14,7 @@
>  #ifndef __ASM_X86_MEM_ACCESS_H__
>  #define __ASM_X86_MEM_ACCESS_H__
>
> +#ifdef CONFIG_VM_EVENT
>  /*
>   * Setup vm_event request based on the access (gla is -1ull if not 
> available).
>   * Handles the rw2rx conversion. Boolean return value indicates if event 
> type @@ -
> 25,6 +26,15 @@  bool p2m_mem_access_check(paddr_t gpa, unsigned long gla,
>                            struct npfec npfec,
>                            struct vm_event_st **req_ptr);
> +#else
> +static inline bool p2m_mem_access_check(paddr_t gpa, unsigned long gla,
> +                                        struct npfec npfec,
> +                                        struct vm_event_st **req_ptr) {
> +    *req_ptr = NULL;
> +    return false;
> +}
> +#endif /* CONFIG_VM_EVENT */
>
>  /* Check for emulation and mark vcpu for skipping one instruction
>   * upon rescheduling if required. */
> --
> 2.34.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.