From nobody Fri Oct 31 03:48:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1752696975; cv=none; d=zohomail.com; s=zohoarc; b=DxaiWjnIjobbJ5g6mnAHvN681Mg+6a3c9uMXBEvOsb/ZbYLzw2nZ4KUtnXEb6J5o8hKkFxG3be/CBSd8C8SNaNNYZM1eXztUgm8KizwA4/h7dVjzxYiZu0y1q744ZvebQdz6SuQQ66t6D3zbQHqoSsrDA82cP+Jj7KKetmInIp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752696975; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oSrj1Q8+f2dC3e/O+6UnVyN9VNRU5k/bRaULjt3iNhY=; b=i46GYlJ0LdmBVII65LQeE9Xxp5QiKlKU47xSmo/NFV6ROuMaGePNtTFzu+U+QGSvs+kpkZAqAnctGLs0qt609vL2SfpFDesn/RwZMp2PLzeOU37o41hlhXuziiy58PD17GFgoCHeNxE1F8aiW8pL++8eBE+j2NByK9ukzAtBA94= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17526969751296.218996343212893; Wed, 16 Jul 2025 13:16:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1045628.1415815 (Exim 4.92) (envelope-from ) id 1uc8Xo-00053G-Ay; Wed, 16 Jul 2025 20:16:00 +0000 Received: by outflank-mailman (output) from mailman id 1045628.1415815; Wed, 16 Jul 2025 20:16:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xo-000537-6a; Wed, 16 Jul 2025 20:16:00 +0000 Received: by outflank-mailman (input) for mailman id 1045628; Wed, 16 Jul 2025 20:15:58 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uc8Xm-0003uY-NS for xen-devel@lists.xenproject.org; Wed, 16 Jul 2025 20:15:58 +0000 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [2a00:1450:4864:20::329]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ae87420f-6281-11f0-b894-0df219b8e170; Wed, 16 Jul 2025 22:15:56 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4535fc0485dso426705e9.0 for ; Wed, 16 Jul 2025 13:15:56 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4562e7f2e8csm30504145e9.5.2025.07.16.13.15.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jul 2025 13:15:55 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ae87420f-6281-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752696956; x=1753301756; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oSrj1Q8+f2dC3e/O+6UnVyN9VNRU5k/bRaULjt3iNhY=; b=DcEbZdDG2uXo2MR9vbyMxrSjCcJoxZ/qxpzBrfUkj2+8yogXh0rWHRkdCSDJMGzpQi nRtIIXyt6HhPbP19y14Gqig3y7gOnfsk//xhX8O0e8JONwRsbjYD/BZlMdcqqQXE2w2X B4qoBTRcJS3dSALSLjCU6U7AJxcFC2ufa9J0UYV3veDbb71MLP0cRw++n884aD3mrsAZ cOw0UgqpR6ITXyrYLEPBaA7qK0jk9poyppTIO15XnCqylGJrwPriNK0EeATLDpoWbuO3 3Y2E9yl/wxhbpHN07JfrIBOt6+RpzSc7DWaRH7MJyc8Rm8IvYOQ/KJfFAiFz6IZhSMLO L20Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752696956; x=1753301756; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oSrj1Q8+f2dC3e/O+6UnVyN9VNRU5k/bRaULjt3iNhY=; b=JkiYfO8a5F00uiyfCtyHID+XrjGyK8AU6SkejD6LeES7/NkqxQjaVsmUjafVwi6Q8b Pgrhjpr+MiORLgPyFiaGJOjSopvSVRUImiG9Ez53iPDL3VHv6Ho/4uMdGkxF4FOUq6dI 4W+SCFwxwmkC3X5Tm1i4Dzqe3kwYEvP8P/VXzZZp/j5BYTWizO1a0FMsp3z+IBdBsc3V oBDlaewqWsS38uiJ8kPHhEe0iD1Lc/HHwFAuk10jINbfzzHrsZJzQMUBXXGpQ/mosN8w QPxNj5tTrScmMeCBvN5MJ9wTACIXeKeKpO2+BqOpBnyPZDEjQWIJ6k1YdP/gIobDOcQp ZI9g== X-Gm-Message-State: AOJu0YxByHfwwNVIeFKctra78I/6gSU8LO8bg293r5ymrfHdWbuD2Ff+ oO1T9QA/o/28ptok42fG93BS+1mOHAJ0K7GWaiz3UKG7Kk+s3E0oadl3t+8QIQ== X-Gm-Gg: ASbGncuk/EIywcxDM15ZbePLtjNVNecST7dmfnuGpA0kzD7eW7TR1NZIkvV1Ak8dEmp mUlCKrZLU45Zlf0uL1220Lvcg9AI9EO2YXpHlS/Dyk8gkoEoahJeQLi4SaHXFWXNdyTI4GxdF24 Rxmn0Rs7ekMTbFEdTGGbSGglTxdenr1XGTsRUvh4hXiiy/XBEgW2mTgjV86iHRg72gtZssOkV3R krZUTUcCwXziY5izn8jtz8EpR2M56WdPGDItSX4ZD8Q3GuM9G8K6MRf0nv15IoBHCWFm5Pb2xoT 2lXR2URuM1OkGqx4bD73XQIYUfIStM8eP18TAjkLyp2T7XxYfWnzQkbT4tdzCHt5E4L1xX9jkJO VT1rN99A2/Mx0RV2+FpRe9lRqsXN8kqOI83TY2vsw5ANti4WtZrh91uMKT62kN+BJyoqN+IjcYI G4PoatDN3NZRtHS+W3wi/flQ== X-Google-Smtp-Source: AGHT+IEf9Eg95JbsVko17BZpPVO1ysf/Tzl8zVpTsn/OD2tBB86LNZNvpyO079mVqPFJ+RjyRScS5w== X-Received: by 2002:a05:6000:2c06:b0:3a3:6a3f:bc61 with SMTP id ffacd0b85a97d-3b60dd65f3fmr1580168f8f.7.1752696955707; Wed, 16 Jul 2025 13:15:55 -0700 (PDT) From: "=?UTF-8?q?Petr=20Bene=C5=A1?=" X-Google-Original-From: =?UTF-8?q?Petr=20Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?UTF-8?q?Petr=20Bene=C5=A1?= , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Tamas K Lengyel , Alexandru Isaila , Petre Pircalabu Subject: [PATCH v10 5/9] x86/altp2m: Wrap altp2m-specific code in #ifdef CONFIG_ALTP2M Date: Wed, 16 Jul 2025 20:15:35 +0000 Message-Id: <35028b36429edbff5f6bf1af6a8168ac055089bd.1752691429.git.w1benny@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1752696977373116600 From: Petr Bene=C5=A1 This change consistently guards all altp2m-related functionality behind #ifdef CONFIG_ALTP2M, so that code and data structures related to alternate p2m views are only included when the feature is enabled. Apart from that: - hvmemul_vmfunc() returns X86EMUL_UNHANDLEABLE when altp2m is disabled. - do_altp2m_op() returns EOPNOTSUPP when altp2m is disabled. - struct hvm_vcpu, arch_domain, and hvm_function_table only define altp2m fields when the feature is enabled. - Moved several declarations under #ifdef CONFIG_ALTP2M in p2m.h to avoid polluting builds that don't require the feature. Signed-off-by: Petr Bene=C5=A1 --- xen/arch/x86/hvm/emulate.c | 10 ++++++++-- xen/arch/x86/hvm/hvm.c | 10 ++++++++++ xen/arch/x86/hvm/vmx/vmx.c | 8 ++++++++ xen/arch/x86/include/asm/domain.h | 2 ++ xen/arch/x86/include/asm/hvm/hvm.h | 8 ++++++++ xen/arch/x86/include/asm/hvm/vcpu.h | 4 ++++ xen/arch/x86/include/asm/p2m.h | 17 ++++++++++++++--- xen/arch/x86/mm/hap/hap.c | 6 ++++++ xen/arch/x86/mm/mem_access.c | 8 ++++++++ xen/arch/x86/mm/p2m-ept.c | 4 ++++ xen/arch/x86/mm/p2m.c | 9 +++++++++ 11 files changed, 81 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index 91f004d233..d933ed3bd3 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -2686,8 +2686,8 @@ static int cf_check hvmemul_tlb_op( return rc; } =20 -static int cf_check hvmemul_vmfunc( - struct x86_emulate_ctxt *ctxt) +#ifdef CONFIG_ALTP2M +static int cf_check hvmemul_vmfunc(struct x86_emulate_ctxt *ctxt) { int rc; =20 @@ -2699,6 +2699,12 @@ static int cf_check hvmemul_vmfunc( =20 return rc; } +#else +static int cf_check hvmemul_vmfunc(struct x86_emulate_ctxt *ctxt) +{ + return X86EMUL_UNHANDLEABLE; +} +#endif =20 static const struct x86_emulate_ops hvm_emulate_ops =3D { .read =3D hvmemul_read, diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 56c7de3977..5183bfea3a 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4608,6 +4608,7 @@ static int hvmop_get_param( static int do_altp2m_op( XEN_GUEST_HANDLE_PARAM(void) arg) { +#ifdef CONFIG_ALTP2M struct xen_hvm_altp2m_op a; struct domain *d =3D NULL; int rc =3D 0; @@ -4944,6 +4945,9 @@ static int do_altp2m_op( rcu_unlock_domain(d); =20 return rc; +#else /* !CONFIG_ALTP2M */ + return -EOPNOTSUPP; +#endif /* CONFIG_ALTP2M */ } =20 DEFINE_XEN_GUEST_HANDLE(compat_hvm_altp2m_op_t); @@ -5235,8 +5239,12 @@ int hvm_debug_op(struct vcpu *v, int32_t op) =20 case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF: v->arch.hvm.single_step =3D false; + +#ifdef CONFIG_ALTP2M v->arch.hvm.fast_single_step.enabled =3D false; v->arch.hvm.fast_single_step.p2midx =3D 0; +#endif + break; =20 default: /* Excluded above */ @@ -5261,6 +5269,7 @@ void hvm_toggle_singlestep(struct vcpu *v) =20 void hvm_fast_singlestep(struct vcpu *v, uint16_t p2midx) { +#ifdef CONFIG_ALTP2M ASSERT(atomic_read(&v->pause_count)); =20 if ( !hvm_is_singlestep_supported() ) @@ -5272,6 +5281,7 @@ void hvm_fast_singlestep(struct vcpu *v, uint16_t p2m= idx) v->arch.hvm.single_step =3D true; v->arch.hvm.fast_single_step.enabled =3D true; v->arch.hvm.fast_single_step.p2midx =3D p2midx; +#endif } =20 /* diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 218cb2c1af..b136d89546 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2416,6 +2416,8 @@ static void cf_check vmx_enable_msr_interception(stru= ct domain *d, uint32_t msr) vmx_set_msr_intercept(v, msr, VMX_MSR_W); } =20 +#ifdef CONFIG_ALTP2M + static void cf_check vmx_vcpu_update_eptp(struct vcpu *v) { struct domain *d =3D v->domain; @@ -2535,6 +2537,8 @@ static bool cf_check vmx_vcpu_emulate_ve(struct vcpu = *v) return rc; } =20 +#endif /* CONFIG_ALTP2M */ + static bool cf_check vmx_get_pending_event( struct vcpu *v, struct x86_event *info) { @@ -2863,10 +2867,12 @@ static struct hvm_function_table __initdata_cf_clob= ber vmx_function_table =3D { .update_vlapic_mode =3D vmx_vlapic_msr_changed, .nhvm_hap_walk_L1_p2m =3D nvmx_hap_walk_L1_p2m, .enable_msr_interception =3D vmx_enable_msr_interception, +#ifdef CONFIG_ALTP2M .altp2m_vcpu_update_p2m =3D vmx_vcpu_update_eptp, .altp2m_vcpu_update_vmfunc_ve =3D vmx_vcpu_update_vmfunc_ve, .altp2m_vcpu_emulate_ve =3D vmx_vcpu_emulate_ve, .altp2m_vcpu_emulate_vmfunc =3D vmx_vcpu_emulate_vmfunc, +#endif .vmtrace_control =3D vmtrace_control, .vmtrace_output_position =3D vmtrace_output_position, .vmtrace_set_option =3D vmtrace_set_option, @@ -4963,6 +4969,7 @@ bool asmlinkage vmx_vmenter_helper(const struct cpu_u= ser_regs *regs) single =3D ept; } =20 +#ifdef CONFIG_ALTP2M if ( altp2m_active(currd) ) { unsigned int i; @@ -4981,6 +4988,7 @@ bool asmlinkage vmx_vmenter_helper(const struct cpu_u= ser_regs *regs) } } } +#endif =20 if ( inv ) __invept(inv =3D=3D 1 ? INVEPT_SINGLE_CONTEXT : INVEPT_ALL_CON= TEXT, diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/d= omain.h index 8c0dea12a5..8749c5eba0 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -351,12 +351,14 @@ struct arch_domain struct p2m_domain *nested_p2m[MAX_NESTEDP2M]; mm_lock_t nested_p2m_lock; =20 +#ifdef CONFIG_ALTP2M /* altp2m: allow multiple copies of host p2m */ bool altp2m_active; struct p2m_domain *altp2m_p2m[MAX_ALTP2M]; mm_lock_t altp2m_list_lock; uint64_t *altp2m_eptp; uint64_t *altp2m_visible_eptp; +#endif #endif =20 /* NB. protected by d->event_lock and by irq_desc[irq].lock */ diff --git a/xen/arch/x86/include/asm/hvm/hvm.h b/xen/arch/x86/include/asm/= hvm/hvm.h index bf8bc2e100..af80acfdd8 100644 --- a/xen/arch/x86/include/asm/hvm/hvm.h +++ b/xen/arch/x86/include/asm/hvm/hvm.h @@ -225,11 +225,13 @@ struct hvm_function_table { =20 void (*enable_msr_interception)(struct domain *d, uint32_t msr); =20 +#ifdef CONFIG_ALTP2M /* Alternate p2m */ void (*altp2m_vcpu_update_p2m)(struct vcpu *v); void (*altp2m_vcpu_update_vmfunc_ve)(struct vcpu *v); bool (*altp2m_vcpu_emulate_ve)(struct vcpu *v); int (*altp2m_vcpu_emulate_vmfunc)(const struct cpu_user_regs *regs); +#endif =20 /* vmtrace */ int (*vmtrace_control)(struct vcpu *v, bool enable, bool reset); @@ -707,6 +709,7 @@ static inline bool hvm_nested_virt_supported(void) return hvm_funcs.caps.nested_virt; } =20 +#ifdef CONFIG_ALTP2M /* updates the current hardware p2m */ static inline void altp2m_vcpu_update_p2m(struct vcpu *v) { @@ -731,6 +734,11 @@ static inline bool altp2m_vcpu_emulate_ve(struct vcpu = *v) } return false; } +#else /* !CONFIG_ALTP2M */ +void altp2m_vcpu_update_p2m(struct vcpu *v); +void altp2m_vcpu_update_vmfunc_ve(struct vcpu *v); +bool altp2m_vcpu_emulate_ve(struct vcpu *v); +#endif /* CONFIG_ALTP2M */ =20 static inline int hvm_vmtrace_control(struct vcpu *v, bool enable, bool re= set) { diff --git a/xen/arch/x86/include/asm/hvm/vcpu.h b/xen/arch/x86/include/asm= /hvm/vcpu.h index 196fed6d5d..924af890c5 100644 --- a/xen/arch/x86/include/asm/hvm/vcpu.h +++ b/xen/arch/x86/include/asm/hvm/vcpu.h @@ -133,10 +133,12 @@ struct hvm_vcpu { bool flag_dr_dirty; bool debug_state_latch; bool single_step; +#ifdef CONFIG_ALTP2M struct { bool enabled; uint16_t p2midx; } fast_single_step; +#endif =20 /* (MFN) hypervisor page table */ pagetable_t monitor_table; @@ -154,7 +156,9 @@ struct hvm_vcpu { =20 struct nestedvcpu nvcpu; =20 +#ifdef CONFIG_ALTP2M struct altp2mvcpu avcpu; +#endif =20 struct mtrr_state mtrr; u64 pat_cr; diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h index 7375895836..4ed93f3a46 100644 --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -889,6 +889,8 @@ void shadow_p2m_init(struct p2m_domain *p2m); void cf_check nestedp2m_write_p2m_entry_post( struct p2m_domain *p2m, unsigned int oflags); =20 +#ifdef CONFIG_ALTP2M + /* * Alternate p2m: shadow p2m tables used for alternate memory views */ @@ -963,13 +965,22 @@ int p2m_altp2m_propagate_change(struct domain *d, gfn= _t gfn, int p2m_set_altp2m_view_visibility(struct domain *d, unsigned int altp2m_i= dx, uint8_t visible); =20 -#ifdef CONFIG_ALTP2M /* Check to see if vcpu should be switched to a different p2m. */ void p2m_altp2m_check(struct vcpu *v, uint16_t idx); -#endif =20 -#else /* !CONFIG_HVM */ +#else /* !CONFIG_ALTP2M */ + struct p2m_domain *p2m_get_altp2m(struct vcpu *v); +bool p2m_set_altp2m(struct vcpu *v, unsigned int idx); +bool p2m_altp2m_get_or_propagate(struct p2m_domain *ap2m, unsigned long gf= n_l, + mfn_t *mfn, p2m_type_t *p2mt, + p2m_access_t *p2ma, unsigned int *page_or= der); +int p2m_altp2m_propagate_change(struct domain *d, gfn_t gfn, + mfn_t mfn, unsigned int page_order, + p2m_type_t p2mt, p2m_access_t p2ma); + +#endif /* CONFIG_ALTP2M */ + #endif /* CONFIG_HVM */ =20 /* p2m access to IOMMU flags */ diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c index ec5043a8aa..384c24028f 100644 --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -494,6 +494,7 @@ int hap_enable(struct domain *d, u32 mode) goto out; } =20 +#ifdef CONFIG_ALTP2M if ( hvm_altp2m_supported() ) { /* Init alternate p2m data */ @@ -524,6 +525,7 @@ int hap_enable(struct domain *d, u32 mode) =20 d->arch.altp2m_active =3D false; } +#endif /* CONFIG_ALTP2M */ =20 /* Now let other users see the new mode */ d->arch.paging.mode =3D mode | PG_HAP_enable; @@ -537,9 +539,11 @@ void hap_final_teardown(struct domain *d) { unsigned int i; =20 +#ifdef CONFIG_ALTP2M if ( hvm_altp2m_supported() ) for ( i =3D 0; i < MAX_ALTP2M; i++ ) p2m_teardown(d->arch.altp2m_p2m[i], true, NULL); +#endif =20 /* Destroy nestedp2m's first */ for (i =3D 0; i < MAX_NESTEDP2M; i++) { @@ -578,6 +582,7 @@ void hap_teardown(struct domain *d, bool *preempted) for_each_vcpu ( d, v ) hap_vcpu_teardown(v); =20 +#ifdef CONFIG_ALTP2M /* Leave the root pt in case we get further attempts to modify the p2m= . */ if ( hvm_altp2m_supported() ) { @@ -597,6 +602,7 @@ void hap_teardown(struct domain *d, bool *preempted) return; } } +#endif =20 /* Destroy nestedp2m's after altp2m. */ for ( i =3D 0; i < MAX_NESTEDP2M; i++ ) diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c index 21b5b7ecda..0779c41161 100644 --- a/xen/arch/x86/mm/mem_access.c +++ b/xen/arch/x86/mm/mem_access.c @@ -347,6 +347,7 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn, ui= nt32_t nr, unsigned long gfn_l; long rc =3D 0; =20 +#ifdef CONFIG_ALTP2M /* altp2m view 0 is treated as the hostp2m */ if ( altp2m_idx ) { @@ -357,6 +358,7 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn, ui= nt32_t nr, =20 ap2m =3D array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); } +#endif =20 if ( !xenmem_access_to_p2m_access(p2m, access, &a) ) return -EINVAL; @@ -403,6 +405,7 @@ long p2m_set_mem_access_multi(struct domain *d, struct p2m_domain *p2m =3D p2m_get_hostp2m(d), *ap2m =3D NULL; long rc =3D 0; =20 +#ifdef CONFIG_ALTP2M /* altp2m view 0 is treated as the hostp2m */ if ( altp2m_idx ) { @@ -413,6 +416,7 @@ long p2m_set_mem_access_multi(struct domain *d, =20 ap2m =3D array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); } +#endif =20 p2m_lock(p2m); if ( ap2m ) @@ -462,6 +466,7 @@ int p2m_get_mem_access(struct domain *d, gfn_t gfn, xen= mem_access_t *access, { struct p2m_domain *p2m =3D p2m_get_hostp2m(d); =20 +#ifdef CONFIG_ALTP2M if ( !altp2m_active(d) ) { if ( altp2m_idx ) @@ -476,6 +481,7 @@ int p2m_get_mem_access(struct domain *d, gfn_t gfn, xen= mem_access_t *access, =20 p2m =3D array_access_nospec(d->arch.altp2m_p2m, altp2m_idx); } +#endif =20 return _p2m_get_mem_access(p2m, gfn, access); } @@ -486,6 +492,7 @@ void arch_p2m_set_access_required(struct domain *d, boo= l access_required) =20 p2m_get_hostp2m(d)->access_required =3D access_required; =20 +#ifdef CONFIG_ALTP2M if ( altp2m_active(d) ) { unsigned int i; @@ -497,6 +504,7 @@ void arch_p2m_set_access_required(struct domain *d, boo= l access_required) p2m->access_required =3D access_required; } } +#endif } =20 bool p2m_mem_access_sanity_check(const struct domain *d) diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 0cf6818c13..86dc538030 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -1297,6 +1297,7 @@ static void ept_set_ad_sync(struct domain *d, bool va= lue) =20 hostp2m->ept.ad =3D value; =20 +#ifdef CONFIG_ALTP2M if ( unlikely(altp2m_active(d)) ) { unsigned int i; @@ -1315,6 +1316,7 @@ static void ept_set_ad_sync(struct domain *d, bool va= lue) p2m_unlock(p2m); } } +#endif } =20 static void ept_enable_pml(struct p2m_domain *p2m) @@ -1506,6 +1508,7 @@ void __init setup_ept_dump(void) register_keyhandler('D', ept_dump_p2m_table, "dump VT-x EPT tables", 0= ); } =20 +#ifdef CONFIG_ALTP2M void p2m_init_altp2m_ept(struct domain *d, unsigned int i) { struct p2m_domain *p2m =3D array_access_nospec(d->arch.altp2m_p2m, i); @@ -1545,6 +1548,7 @@ unsigned int p2m_find_altp2m_by_eptp(struct domain *d= , uint64_t eptp) altp2m_list_unlock(d); return i; } +#endif /* CONFIG_ALTP2M */ =20 /* * Local variables: diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index b9a7c2dc53..5a3fda903e 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -101,6 +101,7 @@ void p2m_change_entry_type_global(struct domain *d, =20 change_entry_type_global(hostp2m, ot, nt); =20 +#ifdef CONFIG_ALTP2M if ( unlikely(altp2m_active(d)) ) { unsigned int i; @@ -117,6 +118,7 @@ void p2m_change_entry_type_global(struct domain *d, } } } +#endif =20 p2m_unlock(hostp2m); } @@ -145,6 +147,7 @@ bool p2m_memory_type_changed(struct domain *d) =20 _memory_type_changed(hostp2m); =20 +#ifdef CONFIG_ALTP2M if ( unlikely(altp2m_active(d)) ) { unsigned int i; @@ -161,6 +164,7 @@ bool p2m_memory_type_changed(struct domain *d) } } } +#endif =20 p2m_unlock(hostp2m); =20 @@ -930,6 +934,7 @@ void p2m_change_type_range(struct domain *d, =20 change_type_range(hostp2m, start, end, ot, nt); =20 +#ifdef CONFIG_ALTP2M if ( unlikely(altp2m_active(d)) ) { unsigned int i; @@ -946,6 +951,8 @@ void p2m_change_type_range(struct domain *d, } } } +#endif + hostp2m->defer_nested_flush =3D false; if ( nestedhvm_enabled(d) ) p2m_flush_nestedp2m(d); @@ -1003,6 +1010,7 @@ int p2m_finish_type_change(struct domain *d, if ( rc < 0 ) goto out; =20 +#ifdef CONFIG_ALTP2M if ( unlikely(altp2m_active(d)) ) { unsigned int i; @@ -1022,6 +1030,7 @@ int p2m_finish_type_change(struct domain *d, } } } +#endif =20 out: p2m_unlock(hostp2m); --=20 2.34.1