From nobody Sat May 4 11:56:10 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=amzn.com ARC-Seal: i=1; a=rsa-sha256; t=1583412389; cv=none; d=zohomail.com; s=zohoarc; b=cHvq4KoULWT9nbSZqMLMa1OpvAbsHogOLk8xHes09M0LjSqml1GF2dtf27TnbTcoWCqn5qAFiA2f7YasvlXZDfhNoQHLL/qlhH42GeE4LynMoDBW0m7Wq1k+Qm9fMm5L2nsBHxDPuh7dQOTLrJgWIEhgkYpBsR8dIbRvoyY4NdU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583412389; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1odjBe5+pmI9dwBeqhCgmtfm1S8uazct9y/Igu3p0Nc=; b=WWrFLlucU9pIm5RuJpVxScmDZ7Lx201+Ljbdo0Q+BQPVx6FkCxKTBAwUBvYXCmvRpe6udsgzPoDIi2Fqic0WCtkNI4ckYniIduZ7X86Te4aHklRb4dkMKg8Ckt/MH1zGpRPNq8wxu2e6EDpkTA2H0bNKWy/c6mSbk6D+FlQLFtA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1583412388953622.8972932958129; Thu, 5 Mar 2020 04:46:28 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j9psr-00007y-Bt; Thu, 05 Mar 2020 12:45:49 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j9psq-00007n-HS for xen-devel@lists.xenproject.org; Thu, 05 Mar 2020 12:45:48 +0000 Received: from smtp-fw-9101.amazon.com (unknown [207.171.184.25]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 3c91ecb6-5edf-11ea-b52f-bc764e2007e4; Thu, 05 Mar 2020 12:45:48 +0000 (UTC) Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1a-821c648d.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP; 05 Mar 2020 12:45:47 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1a-821c648d.us-east-1.amazon.com (Postfix) with ESMTPS id 772B2A28D4; Thu, 5 Mar 2020 12:45:42 +0000 (UTC) Received: from EX13D32EUC004.ant.amazon.com (10.43.164.121) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Thu, 5 Mar 2020 12:45:15 +0000 Received: from EX13MTAUWC001.ant.amazon.com (10.43.162.135) by EX13D32EUC004.ant.amazon.com (10.43.164.121) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 5 Mar 2020 12:45:14 +0000 Received: from u2f063a87eabd5f.cbg10.amazon.com (10.125.106.135) by mail-relay.amazon.com (10.43.162.232) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 5 Mar 2020 12:45:11 +0000 X-Inumbo-ID: 3c91ecb6-5edf-11ea-b52f-bc764e2007e4 IronPort-SDR: fJSXx1pNHHRx+3aLfDl41WnVs5e2C85IGx/uLxgDnVPFmNmoxjpLWnkNzmn6tYoDb/NOlwAX2l RHAvwdPh8b/A== X-IronPort-AV: E=Sophos;i="5.70,518,1574121600"; d="scan'208";a="21060556" From: To: Date: Thu, 5 Mar 2020 12:44:59 +0000 Message-ID: <20200305124504.3564-2-pdurrant@amzn.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200305124504.3564-1-pdurrant@amzn.com> References: <20200305124504.3564-1-pdurrant@amzn.com> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v3 1/6] domain: introduce alloc/free_shared_info() helpers... X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , Andrew Cooper , Paul Durrant , Ian Jackson , George Dunlap , Jan Beulich , Volodymyr Babchuk , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Paul Durrant ... and save the MFN. This patch modifies the 'shared_info' field of struct domain to be a structure comprising an MFN and a virtual address. Allocations are still done from xenheap, so the virtual address still equates to virt_to_mfn() called on the MFN but subsequent patch will change this. Hence the need to save the MFN. NOTE: Whist defining the new helpers, virt_to_mfn() in common/domain.c is made type safe. The definition of nmi_reason() in asm-x86/shared.h is also re- flowed to avoid overly long lines. Signed-off-by: Paul Durrant Reviewed-by: Julien Grall Acked-by: Jan Beulich --- Cc: Stefano Stabellini Cc: Volodymyr Babchuk Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Konrad Rzeszutek Wilk Cc: Wei Liu Cc: "Roger Pau Monn=C3=A9" --- xen/arch/arm/domain.c | 8 ++------ xen/arch/arm/mm.c | 2 +- xen/arch/x86/domain.c | 11 ++++------- xen/arch/x86/mm.c | 2 +- xen/arch/x86/pv/dom0_build.c | 2 +- xen/arch/x86/pv/shim.c | 2 +- xen/common/domain.c | 26 ++++++++++++++++++++++++++ xen/common/domctl.c | 2 +- xen/common/time.c | 4 ++-- xen/include/asm-x86/shared.h | 15 ++++++++------- xen/include/xen/domain.h | 3 +++ xen/include/xen/sched.h | 5 ++++- xen/include/xen/shared.h | 2 +- 13 files changed, 55 insertions(+), 29 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 6627be2922..5298d80bd2 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -689,13 +689,9 @@ int arch_domain_create(struct domain *d, if ( (rc =3D p2m_init(d)) !=3D 0 ) goto fail; =20 - rc =3D -ENOMEM; - if ( (d->shared_info =3D alloc_xenheap_pages(0, 0)) =3D=3D NULL ) + if ( (rc =3D alloc_shared_info(d, 0)) !=3D 0 ) goto fail; =20 - clear_page(d->shared_info); - share_xen_page_with_guest(virt_to_page(d->shared_info), d, SHARE_rw); - switch ( config->arch.gic_version ) { case XEN_DOMCTL_CONFIG_GIC_V2: @@ -766,7 +762,7 @@ void arch_domain_destroy(struct domain *d) p2m_teardown(d); domain_vgic_free(d); domain_vuart_free(d); - free_xenheap_page(d->shared_info); + free_shared_info(d); #ifdef CONFIG_ACPI free_xenheap_pages(d->arch.efi_acpi_table, get_order_from_bytes(d->arch.efi_acpi_len)); diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 727107eefa..2bb592101d 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1424,7 +1424,7 @@ int xenmem_add_to_physmap_one( if ( idx !=3D 0 ) return -EINVAL; =20 - mfn =3D virt_to_mfn(d->shared_info); + mfn =3D d->shared_info.mfn; t =3D p2m_ram_rw; =20 break; diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index caf2ecad7e..bdcc0d972a 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -611,12 +611,9 @@ int arch_domain_create(struct domain *d, * The shared_info machine address must fit in a 32-bit field within a * 32-bit guest's start_info structure. Hence we specify MEMF_bits(32). */ - if ( (d->shared_info =3D alloc_xenheap_pages(0, MEMF_bits(32))) =3D=3D= NULL ) + if ( (rc =3D alloc_shared_info(d, MEMF_bits(32))) !=3D 0 ) goto fail; =20 - clear_page(d->shared_info); - share_xen_page_with_guest(virt_to_page(d->shared_info), d, SHARE_rw); - if ( (rc =3D init_domain_irq_mapping(d)) !=3D 0 ) goto fail; =20 @@ -664,7 +661,7 @@ int arch_domain_create(struct domain *d, psr_domain_free(d); iommu_domain_destroy(d); cleanup_domain_irq_mapping(d); - free_xenheap_page(d->shared_info); + free_shared_info(d); xfree(d->arch.cpuid); xfree(d->arch.msr); if ( paging_initialised ) @@ -693,7 +690,7 @@ void arch_domain_destroy(struct domain *d) pv_domain_destroy(d); free_perdomain_mappings(d); =20 - free_xenheap_page(d->shared_info); + free_shared_info(d); cleanup_domain_irq_mapping(d); =20 psr_domain_free(d); @@ -719,7 +716,7 @@ void arch_domain_unpause(struct domain *d) =20 int arch_domain_soft_reset(struct domain *d) { - struct page_info *page =3D virt_to_page(d->shared_info), *new_page; + struct page_info *page =3D mfn_to_page(d->shared_info.mfn), *new_page; int ret =3D 0; struct domain *owner; mfn_t mfn; diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 62507ca651..ba7563ed3c 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4540,7 +4540,7 @@ int xenmem_add_to_physmap_one( { case XENMAPSPACE_shared_info: if ( idx =3D=3D 0 ) - mfn =3D virt_to_mfn(d->shared_info); + mfn =3D d->shared_info.mfn; break; case XENMAPSPACE_grant_table: rc =3D gnttab_map_frame(d, idx, gpfn, &mfn); diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 5678da782d..dc16ef2e79 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -743,7 +743,7 @@ int __init dom0_construct_pv(struct domain *d, clear_page(si); si->nr_pages =3D nr_pages; =20 - si->shared_info =3D virt_to_maddr(d->shared_info); + si->shared_info =3D mfn_to_maddr(d->shared_info.mfn); =20 if ( !pv_shim ) si->flags =3D SIF_PRIVILEGED | SIF_INITDOMAIN; diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c index d86e2de118..f512809dad 100644 --- a/xen/arch/x86/pv/shim.c +++ b/xen/arch/x86/pv/shim.c @@ -282,7 +282,7 @@ static void write_start_info(struct domain *d) snprintf(si->magic, sizeof(si->magic), "xen-3.0-x86_%s", is_pv_32bit_domain(d) ? "32p" : "64"); si->nr_pages =3D domain_tot_pages(d); - si->shared_info =3D virt_to_maddr(d->shared_info); + si->shared_info =3D mfn_to_maddr(d->shared_info.mfn); si->flags =3D 0; BUG_ON(xen_hypercall_hvm_get_param(HVM_PARAM_STORE_PFN, &si->store_mfn= )); BUG_ON(xen_hypercall_hvm_get_param(HVM_PARAM_STORE_EVTCHN, ¶m)); diff --git a/xen/common/domain.c b/xen/common/domain.c index 6ad458fa6b..ba7a905258 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -47,6 +47,10 @@ #include #endif =20 +/* Override macros from asm/page.h to make them work with mfn_t */ +#undef virt_to_mfn +#define virt_to_mfn(v) _mfn(__virt_to_mfn(v)) + /* Linux config option: propageted to domain0 */ /* xen_processor_pmbits: xen control Cx, Px, ... */ unsigned int xen_processor_pmbits =3D XEN_PROCESSOR_PM_PX; @@ -1644,6 +1648,28 @@ int continue_hypercall_on_cpu( return 0; } =20 +int alloc_shared_info(struct domain *d, unsigned int memflags) +{ + if ( (d->shared_info.virt =3D alloc_xenheap_pages(0, memflags)) =3D=3D= NULL ) + return -ENOMEM; + + d->shared_info.mfn =3D virt_to_mfn(d->shared_info.virt); + + clear_page(d->shared_info.virt); + share_xen_page_with_guest(mfn_to_page(d->shared_info.mfn), d, SHARE_rw= ); + + return 0; +} + +void free_shared_info(struct domain *d) +{ + if ( !d->shared_info.virt ) + return; + + free_xenheap_page(d->shared_info.virt); + d->shared_info.virt =3D NULL; +} + /* * Local variables: * mode: C diff --git a/xen/common/domctl.c b/xen/common/domctl.c index a69b3b59a8..81f18e63a7 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -196,7 +196,7 @@ void getdomaininfo(struct domain *d, struct xen_domctl_= getdomaininfo *info) info->outstanding_pages =3D d->outstanding_pages; info->shr_pages =3D atomic_read(&d->shr_pages); info->paged_pages =3D atomic_read(&d->paged_pages); - info->shared_info_frame =3D mfn_to_gmfn(d, virt_to_mfn(d->shared_info)= ); + info->shared_info_frame =3D mfn_to_gmfn(d, mfn_x(d->shared_info.mfn)); BUG_ON(SHARED_M2P(info->shared_info_frame)); =20 info->cpupool =3D cpupool_get_id(d); diff --git a/xen/common/time.c b/xen/common/time.c index 82336e2d5a..58fa9abc40 100644 --- a/xen/common/time.c +++ b/xen/common/time.c @@ -110,9 +110,9 @@ void update_domain_wallclock_time(struct domain *d) shared_info(d, wc_nsec) =3D wc_nsec; #ifdef CONFIG_X86 if ( likely(!has_32bit_shinfo(d)) ) - d->shared_info->native.wc_sec_hi =3D sec >> 32; + d->shared_info.virt->native.wc_sec_hi =3D sec >> 32; else - d->shared_info->compat.arch.wc_sec_hi =3D sec >> 32; + d->shared_info.virt->compat.arch.wc_sec_hi =3D sec >> 32; #else shared_info(d, wc_sec_hi) =3D sec >> 32; #endif diff --git a/xen/include/asm-x86/shared.h b/xen/include/asm-x86/shared.h index af5d959d04..d4588e08a6 100644 --- a/xen/include/asm-x86/shared.h +++ b/xen/include/asm-x86/shared.h @@ -1,24 +1,25 @@ #ifndef __XEN_X86_SHARED_H__ #define __XEN_X86_SHARED_H__ =20 -#define nmi_reason(d) (!has_32bit_shinfo(d) ? \ - (u32 *)&(d)->shared_info->native.arch.nmi_reason : \ - (u32 *)&(d)->shared_info->compat.arch.nmi_reason) +#define nmi_reason(d) \ + (!has_32bit_shinfo(d) ? \ + (u32 *)&(d)->shared_info.virt->native.arch.nmi_reason : \ + (u32 *)&(d)->shared_info.virt->compat.arch.nmi_reason) =20 #define GET_SET_SHARED(type, field) \ static inline type arch_get_##field(const struct domain *d) \ { \ return !has_32bit_shinfo(d) ? \ - d->shared_info->native.arch.field : \ - d->shared_info->compat.arch.field; \ + d->shared_info.virt->native.arch.field : \ + d->shared_info.virt->compat.arch.field; \ } \ static inline void arch_set_##field(struct domain *d, \ type val) \ { \ if ( !has_32bit_shinfo(d) ) \ - d->shared_info->native.arch.field =3D val; \ + d->shared_info.virt->native.arch.field =3D val; \ else \ - d->shared_info->compat.arch.field =3D val; \ + d->shared_info.virt->compat.arch.field =3D val; \ } =20 #define GET_SET_VCPU(type, field) \ diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 7e51d361de..740e2032ad 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -130,4 +130,7 @@ struct vnuma_info { =20 void vnuma_destroy(struct vnuma_info *vnuma); =20 +int alloc_shared_info(struct domain *d, unsigned int memflags); +void free_shared_info(struct domain *d); + #endif /* __XEN_DOMAIN_H__ */ diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 3a4f43098c..f41d0ad2a0 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -346,7 +346,10 @@ struct domain unsigned int max_vcpus; struct vcpu **vcpu; =20 - shared_info_t *shared_info; /* shared data area */ + struct { + mfn_t mfn; + shared_info_t *virt; + } shared_info; /* shared data area */ =20 spinlock_t domain_lock; =20 diff --git a/xen/include/xen/shared.h b/xen/include/xen/shared.h index a411a8a3e3..57b2ff1e34 100644 --- a/xen/include/xen/shared.h +++ b/xen/include/xen/shared.h @@ -43,7 +43,7 @@ typedef struct vcpu_info vcpu_info_t; =20 extern vcpu_info_t dummy_vcpu_info; =20 -#define shared_info(d, field) __shared_info(d, (d)->shared_info, fiel= d) +#define shared_info(d, field) __shared_info(d, (d)->shared_info.virt,= field) #define vcpu_info(v, field) __vcpu_info(v, (v)->vcpu_info, field) =20 #endif /* __XEN_SHARED_H__ */ --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 11:56:10 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=amzn.com ARC-Seal: i=1; a=rsa-sha256; t=1583412392; cv=none; d=zohomail.com; s=zohoarc; b=izU2qEDB6iMdUMkq0RGkMOXM/+XuS2sPCvrLy+dSaCsfKoHxLLl40xIQlHVR4XJiJHpD01WilfyB88H1WYTmOu1ciofh3Jg9sduMqGcEykY9XLfGOUkAZFm5ihp5CQd4o9oMn4DUskNlJRT8DtPsdM8Ntlf9tmQdnfW3Bx1zrt8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583412392; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oGB5ONrtuhnNpWtsfAky64WVw7zLFBvY7wTuVnWmpDI=; b=drcGTwon92NJbMPzak+fFXZbCRBw3GwWVdL+iUHoTbpnusacI0kzMsbeL6itJ1j44AOEXPakQmxnSyu3DbmNYRZkVXsYNAHMd9q17Sxk6x7X9ek2UWwA10SAoSXp244JRcDgR/Ewh7Nc632iNJ7fINpUCHHGFkE/H98d+NHKh7I= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1583412392443705.2427941975058; Thu, 5 Mar 2020 04:46:32 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j9psw-0000AX-51; Thu, 05 Mar 2020 12:45:54 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j9psv-0000AI-Fb for xen-devel@lists.xenproject.org; Thu, 05 Mar 2020 12:45:53 +0000 Received: from smtp-fw-9101.amazon.com (unknown [207.171.184.25]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 3d1927c6-5edf-11ea-b52f-bc764e2007e4; Thu, 05 Mar 2020 12:45:48 +0000 (UTC) Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP; 05 Mar 2020 12:45:47 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com (Postfix) with ESMTPS id 059D1A2568; Thu, 5 Mar 2020 12:45:44 +0000 (UTC) Received: from EX13D32EUB003.ant.amazon.com (10.43.166.165) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Thu, 5 Mar 2020 12:45:19 +0000 Received: from EX13MTAUWC001.ant.amazon.com (10.43.162.135) by EX13D32EUB003.ant.amazon.com (10.43.166.165) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 5 Mar 2020 12:45:18 +0000 Received: from u2f063a87eabd5f.cbg10.amazon.com (10.125.106.135) by mail-relay.amazon.com (10.43.162.232) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 5 Mar 2020 12:45:15 +0000 X-Inumbo-ID: 3d1927c6-5edf-11ea-b52f-bc764e2007e4 IronPort-SDR: 3b3n3eUG1D8tuzjbvuVJMCoHAjoZu7ezOEAKNJvUTK7gGek8yIXD5anwqyyAx4lNox2rFllQME ig2NcsrXJfZg== X-IronPort-AV: E=Sophos;i="5.70,518,1574121600"; d="scan'208";a="21060558" From: To: Date: Thu, 5 Mar 2020 12:45:00 +0000 Message-ID: <20200305124504.3564-3-pdurrant@amzn.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200305124504.3564-1-pdurrant@amzn.com> References: <20200305124504.3564-1-pdurrant@amzn.com> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v3 2/6] x86 / p2m: remove page_list check in p2m_alloc_table X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Andrew Cooper , Paul Durrant , George Dunlap , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Paul Durrant There does not seem to be any justification for refusing to create the domain's p2m table simply because it may have assigned pages. Particularly it prevents the prior allocation of PGC_extra pages. Signed-off-by: Paul Durrant --- Cc: Jan Beulich Cc: Andrew Cooper Cc: George Dunlap Cc: Wei Liu Cc: "Roger Pau Monn=C3=A9" v2: - New in v2 --- xen/arch/x86/mm/p2m.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 3719deae77..9fd4b115be 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -695,14 +695,6 @@ int p2m_alloc_table(struct p2m_domain *p2m) =20 p2m_lock(p2m); =20 - if ( p2m_is_hostp2m(p2m) - && !page_list_empty(&d->page_list) ) - { - P2M_ERROR("dom %d already has memory allocated\n", d->domain_id); - p2m_unlock(p2m); - return -EINVAL; - } - if ( pagetable_get_pfn(p2m_get_pagetable(p2m)) !=3D 0 ) { P2M_ERROR("p2m already allocated for this domain\n"); --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 11:56:10 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=amzn.com ARC-Seal: i=1; a=rsa-sha256; t=1583412389; cv=none; d=zohomail.com; s=zohoarc; b=Atf9S0ebIQfkyhKKdFcBvvQ7HitSCPnYRQLP+0OGwHNv6HR3KrGi/BcShKoqj9ihmFG3mWsrOxLBeYRfOnrAyfoEVLsUJXBM0mkNGfJnz3k9j+cHlPM0peRj8WZe33y3ZfGFN9IcEvO8tQB3Z6cCvK+3fa8UbtOETEVhspgZUag= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583412389; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6QDyqyT1VQE8fdR8FFBrUE8/KmFw91wk81WUix16EAQ=; b=SFhjFRfXhjG7Bh7lC/VyEmX2ShV5dwaoeLv0CIjGsD2yCrkBLLfnBl3wr6i/2nc8g3e7WYgjyFa+FyzWz9xW8N6A48VhPFyZdRnXuqri7EC77dFPQjleKCAnl/g+a7WBYjUgktIJNFpyCO3hP+0GGTzx+J0m/4C5rHj+q3+wHys= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1583412389317423.06724841997186; Thu, 5 Mar 2020 04:46:29 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j9pst-00008w-L0; Thu, 05 Mar 2020 12:45:51 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j9pss-00008X-6D for xen-devel@lists.xenproject.org; Thu, 05 Mar 2020 12:45:50 +0000 Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 3c4fe123-5edf-11ea-a5ab-12813bfff9fa; Thu, 05 Mar 2020 12:45:49 +0000 (UTC) Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1e-303d0b0e.us-east-1.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 05 Mar 2020 12:45:48 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-303d0b0e.us-east-1.amazon.com (Postfix) with ESMTPS id 33ABBA285B; Thu, 5 Mar 2020 12:45:47 +0000 (UTC) Received: from EX13D32EUB002.ant.amazon.com (10.43.166.114) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Thu, 5 Mar 2020 12:45:22 +0000 Received: from EX13MTAUWC001.ant.amazon.com (10.43.162.135) by EX13D32EUB002.ant.amazon.com (10.43.166.114) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 5 Mar 2020 12:45:21 +0000 Received: from u2f063a87eabd5f.cbg10.amazon.com (10.125.106.135) by mail-relay.amazon.com (10.43.162.232) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 5 Mar 2020 12:45:18 +0000 X-Inumbo-ID: 3c4fe123-5edf-11ea-a5ab-12813bfff9fa IronPort-SDR: zZOrVuJ/CmK1rDTTlmHwh+HBGTzlQ96vPhhgWufdMoyMeDFDehlybuI+0jQIgveS4w4SVQXi9+ dBAtExKMG/sw== X-IronPort-AV: E=Sophos;i="5.70,518,1574121600"; d="scan'208";a="20189940" From: To: Date: Thu, 5 Mar 2020 12:45:01 +0000 Message-ID: <20200305124504.3564-4-pdurrant@amzn.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200305124504.3564-1-pdurrant@amzn.com> References: <20200305124504.3564-1-pdurrant@amzn.com> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v3 3/6] x86 / pv: do not treat PGC_extra pages as RAM when constructing dom0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Paul Durrant , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Paul Durrant The walk of page_list in dom0_construct_pv() should ignore PGC_extra pages as they are only created for special purposes and, if mapped, will be mapped explicitly for whatever purpose is relevant. Signed-off-by: Paul Durrant --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monn=C3=A9" v2: - New in v2 --- xen/arch/x86/pv/dom0_build.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index dc16ef2e79..f8f1bbe2f4 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -792,6 +792,10 @@ int __init dom0_construct_pv(struct domain *d, { mfn =3D mfn_x(page_to_mfn(page)); BUG_ON(SHARED_M2P(get_gpfn_from_mfn(mfn))); + + if ( page->count_info & PGC_extra ) + continue; + if ( get_gpfn_from_mfn(mfn) >=3D count ) { BUG_ON(is_pv_32bit_domain(d)); --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 11:56:10 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=amzn.com ARC-Seal: i=1; a=rsa-sha256; t=1583412398; cv=none; d=zohomail.com; s=zohoarc; b=WMiCBEjYzgPNdDaVQjrce16r/uuy8wxXdx9oNd4r+eKY30Ebhjbf4Uq7LiePJLY0c9O3Ha5+eujJaLPw96YxOweV2/HmiZ9hvKtbjNRgN0QzMTRxQtPVV9ZvHdzRB7zKW6OHym9usfqQISKGYB3nHbkKgrTN3IVF0XBouEKOCos= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583412398; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4K61NmG80h/+CybprS6Bnx458P2iV2HiqAAYVipF2RI=; b=a2W4L79v9Pu6iIDHxG3dInyqtFxnEFpPV9pTFQMNcQLZvclzgnrvg2BI66OVtxhqEUiEzTmyf6rSbAz33uauMe4v3IZo1Q81XI4iepg384IXq5LpqZPMdiIBhQbPFhfg5QORfjWMGZ4ptm1eQO7a72mOFY9G+PqqLy2N5JNaDZ8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1583412398354744.0561837515774; Thu, 5 Mar 2020 04:46:38 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j9ptD-0000Jy-53; Thu, 05 Mar 2020 12:46:11 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j9ptC-0000JL-5x for xen-devel@lists.xenproject.org; Thu, 05 Mar 2020 12:46:10 +0000 Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 45d35ad0-5edf-11ea-a5ab-12813bfff9fa; Thu, 05 Mar 2020 12:46:03 +0000 (UTC) Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-57e1d233.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 05 Mar 2020 12:45:51 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-57e1d233.us-east-1.amazon.com (Postfix) with ESMTPS id ACBB5141A19; Thu, 5 Mar 2020 12:45:49 +0000 (UTC) Received: from EX13D32EUB001.ant.amazon.com (10.43.166.125) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Thu, 5 Mar 2020 12:45:25 +0000 Received: from EX13MTAUWC001.ant.amazon.com (10.43.162.135) by EX13D32EUB001.ant.amazon.com (10.43.166.125) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 5 Mar 2020 12:45:24 +0000 Received: from u2f063a87eabd5f.cbg10.amazon.com (10.125.106.135) by mail-relay.amazon.com (10.43.162.232) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 5 Mar 2020 12:45:21 +0000 X-Inumbo-ID: 45d35ad0-5edf-11ea-a5ab-12813bfff9fa IronPort-SDR: kmwkjSpi7nyQdAyvgGyGweJWpAMUll9j5zNw65ztZ7f7yXRU+rL4RzNc5VbeZqHpu8s6Kg/ad+ ER2Wq35AWVyg== X-IronPort-AV: E=Sophos;i="5.70,518,1574121600"; d="scan'208";a="21158385" From: To: Date: Thu, 5 Mar 2020 12:45:02 +0000 Message-ID: <20200305124504.3564-5-pdurrant@amzn.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200305124504.3564-1-pdurrant@amzn.com> References: <20200305124504.3564-1-pdurrant@amzn.com> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v3 4/6] x86 / ioreq: use a MEMF_no_refcount allocation for server pages... X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Paul Durrant , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Paul Durrant ... now that it is safe to assign them. This avoids relying on libxl (or whatever toolstack is in use) setting max_pages up with sufficient 'slop' to allow all necessary ioreq server pages to be allocated. Signed-off-by: Paul Durrant Reviewed-by: Jan Beulich --- Cc: Paul Durrant Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monn=C3=A9" v2: - New in v2 --- xen/arch/x86/hvm/ioreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/ioreq.c b/xen/arch/x86/hvm/ioreq.c index f8a5c81546..648ef9137f 100644 --- a/xen/arch/x86/hvm/ioreq.c +++ b/xen/arch/x86/hvm/ioreq.c @@ -375,7 +375,7 @@ static int hvm_alloc_ioreq_mfn(struct hvm_ioreq_server = *s, bool buf) return 0; } =20 - page =3D alloc_domheap_page(s->target, 0); + page =3D alloc_domheap_page(s->target, MEMF_no_refcount); =20 if ( !page ) return -ENOMEM; --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 11:56:10 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=amzn.com ARC-Seal: i=1; a=rsa-sha256; t=1583412392; cv=none; d=zohomail.com; s=zohoarc; b=iOPWeZtdwQ5aMZFKk3WX3Dec24CmHBzJyhhzWEHVQlLCdX6iuI0V7ouLU2d8vp2wLGQhkt4xgUlZguRDTLXN8rWE5R9gzxprdY2+pSg7n1umABSqy4XwtHuHylrn2rXdLRAT6ibH7/a2uyu8eALS7AuFW2Lf81WHLTaMgf4/5O8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583412392; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=foGk4+4b5FNhwGHvbuPLDuU0a/CdT2fHAg4r9Bc99vw=; b=Kg1BhNkESPy8LDVv1amw26ize3IaBvlZ68tYgi64wic8Vc4kT8UKhWdgFuPP/VGMvM5KwQOkMC2nhuMnMO3JADpMTZoaPeWgESCoFjKwiQ4yyLmmtZYp0UDmfvyC7kY/EadRMbvbWRj/ICw3lTZCKNl2K6T92v2J35WFeR5O6h4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1583412392047417.499199738342; Thu, 5 Mar 2020 04:46:32 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j9psy-0000C0-Fx; Thu, 05 Mar 2020 12:45:56 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j9psx-0000BT-9J for xen-devel@lists.xenproject.org; Thu, 05 Mar 2020 12:45:55 +0000 Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 410aae54-5edf-11ea-a5ab-12813bfff9fa; Thu, 05 Mar 2020 12:45:55 +0000 (UTC) Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1e-57e1d233.us-east-1.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 05 Mar 2020 12:45:54 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-57e1d233.us-east-1.amazon.com (Postfix) with ESMTPS id 6D428141701; Thu, 5 Mar 2020 12:45:52 +0000 (UTC) Received: from EX13D32EUC002.ant.amazon.com (10.43.164.94) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Thu, 5 Mar 2020 12:45:29 +0000 Received: from EX13MTAUWC001.ant.amazon.com (10.43.162.135) by EX13D32EUC002.ant.amazon.com (10.43.164.94) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 5 Mar 2020 12:45:28 +0000 Received: from u2f063a87eabd5f.cbg10.amazon.com (10.125.106.135) by mail-relay.amazon.com (10.43.162.232) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 5 Mar 2020 12:45:24 +0000 X-Inumbo-ID: 410aae54-5edf-11ea-a5ab-12813bfff9fa IronPort-SDR: Cip1udAXb6lJO2oXSx9LrmNaIBtdhlo3tX0cbLxlLR4gospS27frWYhf6Gh/aee7XomGfDIHIo IbkptYmwx/8g== X-IronPort-AV: E=Sophos;i="5.70,518,1574121600"; d="scan'208";a="20189956" From: To: Date: Thu, 5 Mar 2020 12:45:03 +0000 Message-ID: <20200305124504.3564-6-pdurrant@amzn.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200305124504.3564-1-pdurrant@amzn.com> References: <20200305124504.3564-1-pdurrant@amzn.com> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v3 5/6] mm: add 'is_special_page' macro... X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , Andrew Cooper , Paul Durrant , Ian Jackson , George Dunlap , Tim Deegan , Tamas K Lengyel , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Paul Durrant ... to cover xenheap and PGC_extra pages. PGC_extra pages are intended to hold data structures that are associated with a domain and my be mapped by that domain. They should not be treated as 'normal' guest pages (i.e. RAM or page tables). Hence, in many cases where code currently tests is_xen_heap_page() it should also check for the PGC_extra bit in 'count_info'. This patch therefore defines is_special_page() to cover both cases and converts tests if is_xen_heap_page() to is_special_page() where appropriate. Signed-off-by: Paul Durrant --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monn=C3=A9" Cc: George Dunlap Cc: Ian Jackson Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tamas K Lengyel Cc: Tim Deegan v3: - Delete obsolete comment. v2: - New in v2 --- xen/arch/x86/domctl.c | 2 +- xen/arch/x86/mm.c | 9 ++++----- xen/arch/x86/mm/altp2m.c | 2 +- xen/arch/x86/mm/mem_sharing.c | 3 +-- xen/arch/x86/mm/shadow/common.c | 13 ++++++++----- xen/include/xen/mm.h | 3 +++ 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index ed86762fa6..add70126b9 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -394,7 +394,7 @@ long arch_do_domctl( page =3D get_page_from_gfn(d, gfn, &t, P2M_ALLOC); =20 if ( unlikely(!page) || - unlikely(is_xen_heap_page(page)) ) + unlikely(is_special_page(page)) ) { if ( unlikely(p2m_is_broken(t)) ) type =3D XEN_DOMCTL_PFINFO_BROKEN; diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index ba7563ed3c..353bde5c2c 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -1014,7 +1014,7 @@ get_page_from_l1e( unsigned long cacheattr =3D pte_flags_to_cacheattr(l1f); int err; =20 - if ( is_xen_heap_page(page) ) + if ( is_special_page(page) ) { if ( write ) put_page_type(page); @@ -2447,7 +2447,7 @@ static int cleanup_page_mappings(struct page_info *pa= ge) { page->count_info &=3D ~PGC_cacheattr_mask; =20 - BUG_ON(is_xen_heap_page(page)); + BUG_ON(is_special_page(page)); =20 rc =3D update_xen_mappings(mfn, 0); } @@ -2477,7 +2477,7 @@ static int cleanup_page_mappings(struct page_info *pa= ge) rc =3D rc2; } =20 - if ( likely(!is_xen_heap_page(page)) ) + if ( likely(!is_special_page(page)) ) { ASSERT((page->u.inuse.type_info & (PGT_type_mask | PGT_count_mask)) =3D=3D PGT_writable_= page); @@ -4216,8 +4216,7 @@ int steal_page( if ( !(owner =3D page_get_owner_and_reference(page)) ) goto fail; =20 - if ( owner !=3D d || is_xen_heap_page(page) || - (page->count_info & PGC_extra) ) + if ( owner !=3D d || is_special_page(page) ) goto fail_put; =20 /* diff --git a/xen/arch/x86/mm/altp2m.c b/xen/arch/x86/mm/altp2m.c index 50768f2547..c091b03ea3 100644 --- a/xen/arch/x86/mm/altp2m.c +++ b/xen/arch/x86/mm/altp2m.c @@ -77,7 +77,7 @@ int altp2m_vcpu_enable_ve(struct vcpu *v, gfn_t gfn) * pageable() predicate for this, due to it having the same properties * that we want. */ - if ( !p2m_is_pageable(p2mt) || is_xen_heap_page(pg) ) + if ( !p2m_is_pageable(p2mt) || is_special_page(pg) ) { rc =3D -EINVAL; goto err; diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index 3835bc928f..f49f27a3ef 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -840,9 +840,8 @@ static int nominate_page(struct domain *d, gfn_t gfn, if ( !p2m_is_sharable(p2mt) ) goto out; =20 - /* Skip xen heap pages */ page =3D mfn_to_page(mfn); - if ( !page || is_xen_heap_page(page) ) + if ( !page || is_special_page(page) ) goto out; =20 /* Check if there are mem_access/remapped altp2m entries for this page= */ diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/commo= n.c index cba3ab1eba..e835940d86 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -2087,19 +2087,22 @@ static int sh_remove_all_mappings(struct domain *d,= mfn_t gmfn, gfn_t gfn) * The qemu helper process has an untyped mapping of this dom's RAM * and the HVM restore program takes another. * Also allow one typed refcount for - * - Xen heap pages, to match share_xen_page_with_guest(), - * - ioreq server pages, to match prepare_ring_for_helper(). + * - special pages, which are explicitly referenced and mapped by + * Xen. + * - ioreq server pages, which may be special pages or normal + * guest pages with an extra reference taken by + * prepare_ring_for_helper(). */ if ( !(shadow_mode_external(d) && (page->count_info & PGC_count_mask) <=3D 3 && ((page->u.inuse.type_info & PGT_count_mask) - =3D=3D (is_xen_heap_page(page) || + =3D=3D (is_special_page(page) || (is_hvm_domain(d) && is_ioreq_server_page(d, page))= ))) ) printk(XENLOG_G_ERR "can't find all mappings of mfn %"PRI_mfn - " (gfn %"PRI_gfn"): c=3D%lx t=3D%lx x=3D%d i=3D%d\n", + " (gfn %"PRI_gfn"): c=3D%lx t=3D%lx s=3D%d i=3D%d\n", mfn_x(gmfn), gfn_x(gfn), page->count_info, page->u.inuse.type_info, - !!is_xen_heap_page(page), + !!is_special_page(page), (is_hvm_domain(d) && is_ioreq_server_page(d, page))); } =20 diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index d0d095d9c7..3a57c9177f 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -285,6 +285,9 @@ extern struct domain *dom_cow; =20 #include =20 +#define is_special_page(page) \ + (is_xen_heap_page(page) || ((page)->count_info & PGC_extra)) + #ifndef page_list_entry struct page_list_head { --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 11:56:10 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=amzn.com ARC-Seal: i=1; a=rsa-sha256; t=1583412404; cv=none; d=zohomail.com; s=zohoarc; b=mVncokVW1adfeAW/xG5CTIvTjipUOEgcOQe8zVPdFF76FAKp7Ra3e3RrTYOI4blebq/KQoZiV67g1Rz1+KujVnRGR7OVkpaICo4lexaLh5SspmACKij/5QIzQM4uNeu0Y7EOK5ay3Dc23+NGXvZTLZnjs2sub1JCo2L4o2KZ+JA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583412404; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CjwEmdpb+uP5CGcuSiHKu2mbmA4jvZwg5mvvhLQX9Jo=; b=HjLLURESM/dwu/yAvHsEcF3CS3WoVv4zlpV0SWC+wGjiZOSzCxTvMeHeA+P+3TzatT7DtLEgeJcoGQzV5rHlo89Vbqk1s2DoMuUXVpb02TSA+tza1noi9hyqam7JSRpnarXy42V70StH5mSS01hGLvOk60KJ8EqesvVacu/CS7Q= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1583412404594880.8431556246118; Thu, 5 Mar 2020 04:46:44 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j9pt8-0000HI-RB; Thu, 05 Mar 2020 12:46:06 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j9pt7-0000GW-5f for xen-devel@lists.xenproject.org; Thu, 05 Mar 2020 12:46:05 +0000 Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 43a48d6a-5edf-11ea-a5ab-12813bfff9fa; Thu, 05 Mar 2020 12:45:59 +0000 (UTC) Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 05 Mar 2020 12:45:59 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com (Postfix) with ESMTPS id 27C91A221B; Thu, 5 Mar 2020 12:45:54 +0000 (UTC) Received: from EX13D32EUB001.ant.amazon.com (10.43.166.125) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Thu, 5 Mar 2020 12:45:33 +0000 Received: from EX13MTAUWC001.ant.amazon.com (10.43.162.135) by EX13D32EUB001.ant.amazon.com (10.43.166.125) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 5 Mar 2020 12:45:32 +0000 Received: from u2f063a87eabd5f.cbg10.amazon.com (10.125.106.135) by mail-relay.amazon.com (10.43.162.232) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 5 Mar 2020 12:45:29 +0000 X-Inumbo-ID: 43a48d6a-5edf-11ea-a5ab-12813bfff9fa IronPort-SDR: sKPqtfz/0FyqR4oVGknUH/rjvyq0S+XE3NOP8uztHDCB/hWn79TFU4ycBDWU8yyPQMcNs3KLlc jExnyaJz60Uw== X-IronPort-AV: E=Sophos;i="5.70,518,1574121600"; d="scan'208";a="29429131" From: To: Date: Thu, 5 Mar 2020 12:45:04 +0000 Message-ID: <20200305124504.3564-7-pdurrant@amzn.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200305124504.3564-1-pdurrant@amzn.com> References: <20200305124504.3564-1-pdurrant@amzn.com> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v3 6/6] domain: use PGC_extra domheap page for shared_info X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , Andrew Cooper , Paul Durrant , Ian Jackson , George Dunlap , Jan Beulich , Volodymyr Babchuk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Paul Durrant Currently shared_info is a shared xenheap page but shared xenheap pages complicate future plans for live-update of Xen so it is desirable to, where possible, not use them [1]. This patch therefore converts shared_info into a PGC_extra domheap page. This does entail freeing shared_info during domain_relinquish_resources() rather than domain_destroy() so care is needed to avoid de-referencing a NULL shared_info pointer hence some extra checks of 'is_dying' are needed. NOTE: For Arm, the call to free_shared_info() in arch_domain_destroy() is left in place since it is idempotent and called in the error path for arch_domain_create(). [1] See https://lists.xenproject.org/archives/html/xen-devel/2020-02/msg020= 18.html Signed-off-by: Paul Durrant --- Cc: Stefano Stabellini Cc: Julien Grall Cc: Volodymyr Babchuk Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Konrad Rzeszutek Wilk Cc: Wei Liu v2: - Addressed comments from Julien - Expanded the commit comment to explain why this patch is wanted --- xen/arch/arm/domain.c | 2 ++ xen/arch/x86/domain.c | 3 ++- xen/common/domain.c | 28 ++++++++++++++++++++++++---- xen/common/event_channel.c | 3 +++ xen/common/time.c | 15 +++++++++++++++ 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 5298d80bd2..741f6dd444 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -1005,6 +1005,8 @@ int domain_relinquish_resources(struct domain *d) BUG(); } =20 + free_shared_info(d); + return 0; } =20 diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index bdcc0d972a..15db476646 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -690,7 +690,6 @@ void arch_domain_destroy(struct domain *d) pv_domain_destroy(d); free_perdomain_mappings(d); =20 - free_shared_info(d); cleanup_domain_irq_mapping(d); =20 psr_domain_free(d); @@ -2245,6 +2244,8 @@ int domain_relinquish_resources(struct domain *d) if ( is_hvm_domain(d) ) hvm_domain_relinquish_resources(d); =20 + free_shared_info(d); + return 0; } =20 diff --git a/xen/common/domain.c b/xen/common/domain.c index ba7a905258..886206f648 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1650,24 +1650,44 @@ int continue_hypercall_on_cpu( =20 int alloc_shared_info(struct domain *d, unsigned int memflags) { - if ( (d->shared_info.virt =3D alloc_xenheap_pages(0, memflags)) =3D=3D= NULL ) + struct page_info *pg; + + pg =3D alloc_domheap_page(d, MEMF_no_refcount | memflags); + if ( !pg ) return -ENOMEM; =20 - d->shared_info.mfn =3D virt_to_mfn(d->shared_info.virt); + if ( !get_page_and_type(pg, d, PGT_writable_page) ) + { + /* + * The domain should not be running at this point so there is + * no way we should reach this error path. + */ + ASSERT_UNREACHABLE(); + return -ENODATA; + } + + d->shared_info.mfn =3D page_to_mfn(pg); + d->shared_info.virt =3D __map_domain_page_global(pg); =20 clear_page(d->shared_info.virt); - share_xen_page_with_guest(mfn_to_page(d->shared_info.mfn), d, SHARE_rw= ); =20 return 0; } =20 void free_shared_info(struct domain *d) { + struct page_info *pg; + if ( !d->shared_info.virt ) return; =20 - free_xenheap_page(d->shared_info.virt); + unmap_domain_page_global(d->shared_info.virt); d->shared_info.virt =3D NULL; + + pg =3D mfn_to_page(d->shared_info.mfn); + + put_page_alloc_ref(pg); + put_page_and_type(pg); } =20 /* diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index e86e2bfab0..a17422284d 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -1325,6 +1325,9 @@ void evtchn_destroy(struct domain *d) { unsigned int i; =20 + /* This must be done before shared_info is freed */ + BUG_ON(!d->shared_info.virt); + /* After this barrier no new event-channel allocations can occur. */ BUG_ON(!d->is_dying); spin_barrier(&d->event_lock); diff --git a/xen/common/time.c b/xen/common/time.c index 58fa9abc40..ada02faf07 100644 --- a/xen/common/time.c +++ b/xen/common/time.c @@ -99,6 +99,18 @@ void update_domain_wallclock_time(struct domain *d) uint32_t *wc_version; uint64_t sec; =20 + if ( d !=3D current->domain ) + { + /* + * We need to check is_dying here as, if it is set, the + * shared_info may have been freed. To do this safely we need + * hold the domain lock. + */ + domain_lock(d); + if ( d->is_dying ) + goto unlock; + } + spin_lock(&wc_lock); =20 wc_version =3D &shared_info(d, wc_version); @@ -121,6 +133,9 @@ void update_domain_wallclock_time(struct domain *d) *wc_version =3D version_update_end(*wc_version); =20 spin_unlock(&wc_lock); + unlock: + if ( d !=3D current->domain ) + domain_unlock(d); } =20 /* Set clock to after 00:00:00 UTC, 1 January, 1970. */ --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel