From nobody Thu Oct 30 19:00:04 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=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1753778333; cv=none; d=zohomail.com; s=zohoarc; b=JG6j0F5vznAGJkdxszue7vmYgNpghkw6qMMdcnzNxk2osUAdXCnKQS8zG34itIt52KkRJqOOKiOkppkTjp3NR96DCd1X63U3SFkLQu0uLvINwT3OU90O0sDMolKknSrbjRv+HIkWvxf5QAjjOd4Q5bqBE1KwxUS9yJYAZ848TU8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753778333; h=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=CLWigXSSvWCPOHny9+80GIZMDELoRcydrTbBzab8nks=; b=f/b5hqcpygm88kxY0TOORwKJwkhmnpNKnhtPK/RsAuUPDU1czQejZPHacsUklTb6HBDT16aPYu/l0JX+LxBpgc564M4Bw7FpS/rF8WG3m5VnTMa9RmGL7pvFzk2Sqsl3aygQqLj/nPmAyiybMoCUp54UN+7gjUX5int4SsfJMO8= 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=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 175377833292133.88041359190743; Tue, 29 Jul 2025 01:38:52 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1062195.1427847 (Exim 4.92) (envelope-from ) id 1ugfr8-00012l-7H; Tue, 29 Jul 2025 08:38:42 +0000 Received: by outflank-mailman (output) from mailman id 1062195.1427847; Tue, 29 Jul 2025 08:38: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 1ugfr8-00012e-2g; Tue, 29 Jul 2025 08:38:42 +0000 Received: by outflank-mailman (input) for mailman id 1062195; Tue, 29 Jul 2025 08:38: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 1ugfr6-0000jP-PT for xen-devel@lists.xenproject.org; Tue, 29 Jul 2025 08:38:40 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6c9c7187-6c57-11f0-b895-0df219b8e170; Tue, 29 Jul 2025 10:38:39 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4B54E21A28; Tue, 29 Jul 2025 08:38:38 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1FAB313A8A; Tue, 29 Jul 2025 08:38:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id +7dGBo6IiGi3PwAAD6G6ig (envelope-from ); Tue, 29 Jul 2025 08:38:38 +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 Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6c9c7187-6c57-11f0-b895-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1753778318; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CLWigXSSvWCPOHny9+80GIZMDELoRcydrTbBzab8nks=; b=VJ/nTw/y8gGPwyZVPt78qGyt956qY5elh2dfL0Wk5z8YGPbL8C7qvnsTnBR69MT3qf7YSo NWbcLDrh64TsdxG+RJcxDUfsJIsMSP+B2dQplHs9HiwTPTfBjbs5FqsRnJQ9R5sV8slOmq lvuCVGwfvwyjqbA/y83/pd4vHLttA9s= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b="VJ/nTw/y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1753778318; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CLWigXSSvWCPOHny9+80GIZMDELoRcydrTbBzab8nks=; b=VJ/nTw/y8gGPwyZVPt78qGyt956qY5elh2dfL0Wk5z8YGPbL8C7qvnsTnBR69MT3qf7YSo NWbcLDrh64TsdxG+RJcxDUfsJIsMSP+B2dQplHs9HiwTPTfBjbs5FqsRnJQ9R5sV8slOmq lvuCVGwfvwyjqbA/y83/pd4vHLttA9s= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH v2 1/2] mm: provide a way to do very early page table allocations Date: Tue, 29 Jul 2025 10:38:28 +0200 Message-ID: <20250729083829.11038-2-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250729083829.11038-1-jgross@suse.com> References: <20250729083829.11038-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: X-Spam-Flag: NO X-Rspamd-Queue-Id: 4B54E21A28 X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:dkim,suse.com:mid,suse.com:email]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; DKIM_TRACE(0.00)[suse.com:+] X-Spam-Score: -3.01 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1753778337103116600 Content-Type: text/plain; charset="utf-8" Add a small pool of statically allocated memory pages to be handed out for very early page table allocations. This will make it possible to do virtual allocations e.g. for mapping the shared info page. Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich --- V2: - add comment (Jan Beulich) - drop N_PT in favor of ARRAY_SIZE() (Jan Beulich) - use 2-dimensional array (Jan Beulich) --- arch/x86/mm.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm.c b/arch/x86/mm.c index ebc85e0d..fd808884 100644 --- a/arch/x86/mm.c +++ b/arch/x86/mm.c @@ -640,13 +640,20 @@ void change_readonly(bool readonly) /* * return a valid PTE for a given virtual address. If PTE does not exist, * allocate page-table pages. + * Provide a small pool for allocating some page tables very early. Those = are + * needed currently for mapping the shared info page, so 2 pages ought to = be + * enough. Add one spare page anyway. */ +static char early_pt[4][PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); +static unsigned int n_early_pt =3D ARRAY_SIZE(early_pt); + static int need_pgt_func(unsigned long va, unsigned int lvl, bool is_leaf, pgentry_t *pte, void *par) { pgentry_t **result =3D par; unsigned long pt_mfn; unsigned long pt_pfn; + unsigned long pt_addr; unsigned int idx; =20 if ( !is_leaf ) @@ -665,7 +672,11 @@ static int need_pgt_func(unsigned long va, unsigned in= t lvl, bool is_leaf, } =20 pt_mfn =3D virt_to_mfn(pte); - pt_pfn =3D virt_to_pfn(alloc_page()); + if ( n_early_pt ) + pt_addr =3D (unsigned long)early_pt[--n_early_pt]; + else + pt_addr =3D alloc_page(); + pt_pfn =3D virt_to_pfn(pt_addr); if ( !pt_pfn ) return -1; idx =3D idx_from_va_lvl(va, lvl); --=20 2.43.0 From nobody Thu Oct 30 19:00:04 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=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1753778339; cv=none; d=zohomail.com; s=zohoarc; b=PRMFkIPmcYWPtCp4vQMuZ/8V/Kx6iN0r+y4Q/K9mK36L9ajjVYuzWebgJanTp0w6e6R/D6cLNkJSmztDYgTqnNvWjxo2LriK1fHGz2aT1Guw6ysi2kMX/mv4RXMLE+YVwKlOmQEyIoosJ2DfIm+X1bWrcmJ4ZEnHXoFCD/f29R0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753778339; h=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=CERsJmvQU3WeCwPSw287LcY2uTCpx9Nl7HfOH3U4bYg=; b=GiteeHazzuu6IC1YCCHVcf2OTyBca3x6S4b9D2NuxbA7XPnZF++T/0L5WF7zgAsEyjg6qQsPZ9v9UzlKtTGuPGWnMbt9oTPF5KAdZJ6IL99MYftt8OUe462Jtl5ZKVF1WziPqSSUVUFoOJKaotQkYKtA67Dxq8SudNQ+1Hmy+ws= 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=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1753778339404852.1940927415291; Tue, 29 Jul 2025 01:38:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1062197.1427857 (Exim 4.92) (envelope-from ) id 1ugfrC-0001LS-Im; Tue, 29 Jul 2025 08:38:46 +0000 Received: by outflank-mailman (output) from mailman id 1062197.1427857; Tue, 29 Jul 2025 08:38:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ugfrC-0001LJ-EI; Tue, 29 Jul 2025 08:38:46 +0000 Received: by outflank-mailman (input) for mailman id 1062197; Tue, 29 Jul 2025 08:38:45 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ugfrB-0000jJ-1c for xen-devel@lists.xenproject.org; Tue, 29 Jul 2025 08:38:45 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 6fbf2f11-6c57-11f0-a31e-13f23c93f187; Tue, 29 Jul 2025 10:38:44 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E25C221285; Tue, 29 Jul 2025 08:38:43 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B1C3113876; Tue, 29 Jul 2025 08:38:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id OJGyKZOIiGi7PwAAD6G6ig (envelope-from ); Tue, 29 Jul 2025 08:38:43 +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 Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6fbf2f11-6c57-11f0-a31e-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1753778324; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CERsJmvQU3WeCwPSw287LcY2uTCpx9Nl7HfOH3U4bYg=; b=IHUwasCNPomztVQWHGFYy+mU7VEVEEHPN/0DrK64x+8S2et2VBq9CPUx3mF6C7yKW0fFGP MqdbiSd4O9wixzfN0lhYXpAXCvSdg6l2TM0WbaP+2zOBWlTuxL3FxTD381vEE7Xtd2Aezi m++EmNYqa8pDg8KkG2YAsvnO1hmH84A= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1753778323; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CERsJmvQU3WeCwPSw287LcY2uTCpx9Nl7HfOH3U4bYg=; b=MuaEzhDf0wVeDikVsIVfH0Yk4PmCCGgBCdyHW4nYChgQyqeMel+CqFN/2+xEwXrNwto/0G LiEclI5UTb4IXan3YbMFY2bkaNFGyE/75TeHQ4KHAfq+8XaulGIRSKsLs7gy2wMM1cSORx qmlJTW1KeuqyrU1QSmIoqitQ7j/Rn74= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH v2 2/2] x86: don't use a memory page for mapping the shared info page Date: Tue, 29 Jul 2025 10:38:29 +0200 Message-ID: <20250729083829.11038-3-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250729083829.11038-1-jgross@suse.com> References: <20250729083829.11038-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_THREE(0.00)[4]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -2.80 X-ZohoMail-DKIM: pass (identity @suse.com) (identity @suse.com) X-ZM-MESSAGEID: 1753778340451116600 Content-Type: text/plain; charset="utf-8" There is no need to use a populated memory page for mapping the shared info page at that location. Just use an allocated virtual address for the shared info page. For PVH allocate an unused pfn. Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich --- V2: - don't leak virtual page in map_shared_page() (Jan Beulich) --- arch/x86/mm.c | 7 ------- arch/x86/setup.c | 15 ++++++++------- arch/x86/x86_32.S | 7 +------ arch/x86/x86_64.S | 7 +------ hypervisor.c | 18 ++++++++++++++---- 5 files changed, 24 insertions(+), 30 deletions(-) diff --git a/arch/x86/mm.c b/arch/x86/mm.c index fd808884..2ffef976 100644 --- a/arch/x86/mm.c +++ b/arch/x86/mm.c @@ -498,7 +498,6 @@ static void build_pagetable(unsigned long *start_pfn, u= nsigned long *max_pfn) /* * Mark portion of the address space read only. */ -extern struct shared_info shared_info; =20 struct change_readonly_par { unsigned long etext; @@ -520,12 +519,6 @@ static int change_readonly_func(unsigned long va, unsi= gned int lvl, if ( va + (1UL << ptdata[lvl].shift) > ro->etext ) return 1; =20 - if ( va =3D=3D (unsigned long)&shared_info ) - { - printk("skipped %lx\n", va); - return 0; - } - newval =3D ro->readonly ? (*pte & ~_PAGE_RW) : (*pte | _PAGE_RW); =20 #ifdef CONFIG_PARAVIRT diff --git a/arch/x86/setup.c b/arch/x86/setup.c index 299ff8c7..8fd55c51 100644 --- a/arch/x86/setup.c +++ b/arch/x86/setup.c @@ -47,8 +47,6 @@ shared_info_t *HYPERVISOR_shared_info; */ char stack[2*STACK_SIZE]; =20 -extern char shared_info[PAGE_SIZE]; - static inline void fpu_init(void) { asm volatile("fninit"); } @@ -76,18 +74,21 @@ static void set_info_ptr(start_info_t *ptr) =20 #define hpc_init() =20 +static unsigned long shared_info_va; + shared_info_t *map_shared_info(void) { int rc; - unsigned long pa =3D start_info_ptr->shared_info; =20 - if ( (rc =3D HYPERVISOR_update_va_mapping((unsigned long)shared_info, - __pte(pa | 7), UVMF_INVLPG)) ) + if ( !shared_info_va ) + shared_info_va =3D alloc_virt_kernel(1); + rc =3D map_frame_rw(shared_info_va, PHYS_PFN(start_info_ptr->shared_in= fo)); + if ( rc ) { printk("Failed to map shared_info!! rc=3D%d\n", rc); do_exit(); } - return (shared_info_t *)shared_info; + return (shared_info_t *)shared_info_va; } =20 void unmap_shared_info(void) @@ -95,7 +96,7 @@ void unmap_shared_info(void) int rc; pte_t nullpte =3D { }; =20 - if ( (rc =3D HYPERVISOR_update_va_mapping((unsigned long)shared_info, + if ( (rc =3D HYPERVISOR_update_va_mapping(shared_info_va, nullpte, UVMF_INVLPG)) ) { printk("Failed to unmap shared_info page!! rc=3D%d\n", rc); diff --git a/arch/x86/x86_32.S b/arch/x86/x86_32.S index 3de00277..5d891164 100644 --- a/arch/x86/x86_32.S +++ b/arch/x86/x86_32.S @@ -36,13 +36,8 @@ _start: stack_start: .long stack+(2*__STACK_SIZE), __KERNEL_SS =20 -.globl shared_info, hypercall_page - /* Unpleasant -- the PTE that maps this page is actually overwritt= en */ - /* to map the real shared-info page! :-) = */ .align __PAGE_SIZE -shared_info: - .fill __PAGE_SIZE,1,0 - +.globl hypercall_page hypercall_page: .fill __PAGE_SIZE,1,0 =20 diff --git a/arch/x86/x86_64.S b/arch/x86/x86_64.S index 7529c02e..09b93e39 100644 --- a/arch/x86/x86_64.S +++ b/arch/x86/x86_64.S @@ -33,13 +33,8 @@ _start: stack_start: .quad stack+(2*__STACK_SIZE) =20 -.globl shared_info, hypercall_page - /* Unpleasant -- the PTE that maps this page is actually overwritt= en */ - /* to map the real shared-info page! :-) = */ .align __PAGE_SIZE -shared_info: - .fill __PAGE_SIZE,1,0 - +.globl hypercall_page hypercall_page: .fill __PAGE_SIZE,1,0 =20 diff --git a/hypervisor.c b/hypervisor.c index 6476d658..213eb49d 100644 --- a/hypervisor.c +++ b/hypervisor.c @@ -27,8 +27,10 @@ =20 #include #include +#include #include #include +#include #include =20 EXPORT_SYMBOL(hypercall_page); @@ -37,7 +39,8 @@ EXPORT_SYMBOL(hypercall_page); ((sh)->evtchn_pending[idx] & ~(sh)->evtchn_mask[idx]) =20 #ifndef CONFIG_PARAVIRT -extern shared_info_t shared_info; +static unsigned long shinfo_pfn; +static unsigned long shinfo_va; =20 int hvm_get_parameter(int idx, uint64_t *value) { @@ -69,24 +72,31 @@ shared_info_t *map_shared_info(void) { struct xen_add_to_physmap xatp; =20 + shinfo_pfn =3D e820_get_reserved_pfns(1); xatp.domid =3D DOMID_SELF; xatp.idx =3D 0; xatp.space =3D XENMAPSPACE_shared_info; - xatp.gpfn =3D virt_to_pfn(&shared_info); + xatp.gpfn =3D shinfo_pfn; if ( HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp) !=3D 0 ) BUG(); + if ( !shinfo_va ) + shinfo_va =3D alloc_virt_kernel(1); + if ( !shinfo_va || map_frame_rw(shinfo_va, shinfo_pfn) ) + BUG(); =20 - return &shared_info; + return (shared_info_t *)shinfo_va; } =20 void unmap_shared_info(void) { struct xen_remove_from_physmap xrtp; =20 + unmap_frames(shinfo_va, 1); xrtp.domid =3D DOMID_SELF; - xrtp.gpfn =3D virt_to_pfn(&shared_info); + xrtp.gpfn =3D shinfo_pfn; if ( HYPERVISOR_memory_op(XENMEM_remove_from_physmap, &xrtp) !=3D 0 ) BUG(); + e820_put_reserved_pfns(shinfo_pfn, 1); } #endif =20 --=20 2.43.0