From nobody Mon Feb 9 19:53:26 2026 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 header.i=@amazon.com; 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=quarantine dis=none) header.from=amazon.com ARC-Seal: i=1; a=rsa-sha256; t=1705433222; cv=none; d=zohomail.com; s=zohoarc; b=mDa75/fjAK+vTfFWwVmR8IJ1JCFxWLOviskBWeA9AnzYAGWFRvvYHR71RdAz0A/teDihsZfOKv3pbfNERHwNes7DeipL/CRx2v/xMWyFQ0urqexa/gnIDpfIRvTKz1QJ+cEanLoEXVF9R5Good1FDgseNNquovzgo+v7oCIJmpY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705433222; 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=sWVxwHwgKXZxnYvHw7QOCApWITjaKrfn/x6fPGCt35k=; b=n8n34KRT1krL8MhJA+fQsl7fB0xnJnvKf4qirAix3al23BYm7M+aqfRi2r+Au1AVAzmTW0s1pzZt7ZPdvgVV1SYFNwlMQSZl3BqFV7ldlS/j6SWsJdyGwCQBDxRyr9UFrTK3b5vdT2ZZvt5JnpvuUQ5vDwk0DDa7Uw8GplX6A6o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.com; 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=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1705433222160478.9806859683714; Tue, 16 Jan 2024 11:27:02 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.668091.1040059 (Exim 4.92) (envelope-from ) id 1rPp58-0005ji-Qj; Tue, 16 Jan 2024 19:26:42 +0000 Received: by outflank-mailman (output) from mailman id 668091.1040059; Tue, 16 Jan 2024 19:26:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rPp58-0005fZ-9g; Tue, 16 Jan 2024 19:26:42 +0000 Received: by outflank-mailman (input) for mailman id 668091; Tue, 16 Jan 2024 19:26:40 +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 1rPp56-0002iI-F5 for xen-devel@lists.xenproject.org; Tue, 16 Jan 2024 19:26:40 +0000 Received: from smtp-fw-80009.amazon.com (smtp-fw-80009.amazon.com [99.78.197.220]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2b30fbf2-b4a5-11ee-9b0f-b553b5be7939; Tue, 16 Jan 2024 20:26:38 +0100 (CET) Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1d-m6i4x-d8e96288.us-east-1.amazon.com) ([10.25.36.210]) by smtp-border-fw-80009.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 19:26:36 +0000 Received: from smtpout.prod.us-east-1.prod.farcaster.email.amazon.dev (iad7-ws-svc-p70-lb3-vlan3.iad.amazon.com [10.32.235.38]) by email-inbound-relay-iad-1d-m6i4x-d8e96288.us-east-1.amazon.com (Postfix) with ESMTPS id A011584E30; Tue, 16 Jan 2024 19:26:34 +0000 (UTC) Received: from EX19MTAUEA001.ant.amazon.com [10.0.29.78:62111] by smtpin.naws.us-east-1.prod.farcaster.email.amazon.dev [10.0.3.20:2525] with esmtp (Farcaster) id 526f3352-96b2-47dc-b68e-3f4b8bfe2e83; Tue, 16 Jan 2024 19:26:34 +0000 (UTC) Received: from EX19D008UEC004.ant.amazon.com (10.252.135.170) by EX19MTAUEA001.ant.amazon.com (10.252.134.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Tue, 16 Jan 2024 19:26:30 +0000 Received: from EX19MTAUEB001.ant.amazon.com (10.252.135.35) by EX19D008UEC004.ant.amazon.com (10.252.135.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Tue, 16 Jan 2024 19:26:30 +0000 Received: from dev-dsk-eliasely-1a-fd74790f.eu-west-1.amazon.com (10.253.91.118) by mail-relay.amazon.com (10.252.135.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40 via Frontend Transport; Tue, 16 Jan 2024 19:26:29 +0000 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 Sender: "Xen-devel" X-Inumbo-ID: 2b30fbf2-b4a5-11ee-9b0f-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1705433198; x=1736969198; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sWVxwHwgKXZxnYvHw7QOCApWITjaKrfn/x6fPGCt35k=; b=QdA1Y0FEmSd7CJBzyGz7QvuahXbB+fbPso/yE90GReTaTIXe3Ky2cMlI DW/Rrvm9HBo8MmeZMnJHeTej8adbIycZEdK7J+RANC50cRLnwCr+z7gXj 4LDPzreTMdKbWDyhkz3bNbMkdacgWamMuVeXrztcPvpBcR8EQ4x3irTpP g=; X-IronPort-AV: E=Sophos;i="6.05,200,1701129600"; d="scan'208";a="58701500" X-Farcaster-Flow-ID: 526f3352-96b2-47dc-b68e-3f4b8bfe2e83 From: Elias El Yandouzi To: CC: , , , Hongyan Xia , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Wei Wang , Julien Grall , Elias El Yandouzi Subject: [PATCH v2 (resend) 12/27] x86/mapcache: Initialise the mapcache for the idle domain Date: Tue, 16 Jan 2024 19:25:56 +0000 Message-ID: <20240116192611.41112-13-eliasely@amazon.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240116192611.41112-1-eliasely@amazon.com> References: <20240116192611.41112-1-eliasely@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: Bulk X-ZohoMail-DKIM: pass (identity @amazon.com) X-ZM-MESSAGEID: 1705433223835100005 Content-Type: text/plain; charset="utf-8" From: Hongyan Xia In order to use the mapcache in the idle domain, we also have to populate its page tables in the PERDOMAIN region, and we need to move mapcache_domain_init() earlier in arch_domain_create(). Note, commit 'x86: lift mapcache variable to the arch level' has initialised the mapcache for HVM domains. With this patch, PV, HVM, idle domains now all initialise the mapcache. Signed-off-by: Wei Wang Signed-off-by: Hongyan Xia Signed-off-by: Julien Grall Signed-off-by: Elias El Yandouzi ---- Changes in V2: * Free resources if mapcache initialisation fails * Remove `is_idle_domain()` check from `create_perdomain_mappings= ()` diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 8ef3f7746f..d4c125bc14 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -750,9 +750,16 @@ int arch_domain_create(struct domain *d, =20 spin_lock_init(&d->arch.e820_lock); =20 + if ( (rc =3D mapcache_domain_init(d)) !=3D 0) + { + free_perdomain_mappings(d); + return rc; + } + /* Minimal initialisation for the idle domain. */ if ( unlikely(is_idle_domain(d)) ) { + struct page_info *pg =3D d->arch.perdomain_l3_pg; static const struct arch_csw idle_csw =3D { .from =3D paravirt_ctxt_switch_from, .to =3D paravirt_ctxt_switch_to, @@ -763,6 +770,9 @@ int arch_domain_create(struct domain *d, =20 d->arch.cpu_policy =3D ZERO_BLOCK_PTR; /* Catch stray misuses. */ =20 + idle_pg_table[l4_table_offset(PERDOMAIN_VIRT_START)] =3D + l4e_from_page(pg, __PAGE_HYPERVISOR_RW); + return 0; } =20 @@ -843,8 +853,6 @@ int arch_domain_create(struct domain *d, =20 psr_domain_init(d); =20 - mapcache_domain_init(d); - if ( is_hvm_domain(d) ) { if ( (rc =3D hvm_domain_initialise(d, config)) !=3D 0 ) --=20 2.40.1