From patchwork Tue Jul 12 06:18:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 12914532 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D1AD3C43334 for ; Tue, 12 Jul 2022 06:18:52 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.365481.595651 (Exim 4.92) (envelope-from ) id 1oB9EA-0008PN-Ki; Tue, 12 Jul 2022 06:18:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 365481.595651; Tue, 12 Jul 2022 06:18:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oB9EA-0008PG-Hl; Tue, 12 Jul 2022 06:18:34 +0000 Received: by outflank-mailman (input) for mailman id 365481; Tue, 12 Jul 2022 06:18:33 +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 1oB9E9-0008PA-H1 for xen-devel@lists.xenproject.org; Tue, 12 Jul 2022 06:18:33 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 73ec27f5-01aa-11ed-924f-1f966e50362f; Tue, 12 Jul 2022 08:18:32 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A21B4223FD; Tue, 12 Jul 2022 06:18:31 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7981A13A94; Tue, 12 Jul 2022 06:18:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id w2RIHDcSzWL7dQAAMHmgww (envelope-from ); Tue, 12 Jul 2022 06:18:31 +0000 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: 73ec27f5-01aa-11ed-924f-1f966e50362f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1657606711; 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; bh=etVadWMEcaCmHQolsuZnIQPLKMBgj6AO3enT5B9eJ14=; b=SV9AxBqjGnW7jPyyRN2MIPBldiftwFiA8LPhlTIS6S8WeywkFTOT5WSGOMV/j8tUriDXXK UgHOosw1XJRCKiFerjjFLiHPLnFXzyHFvzCthgGo7e4TMSEei+ktD63+BxLqu3kPxGOV0T 1FewGqHWxqnOf9iOw/12vIjm/UHSu5Q= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Anthony PERARD Subject: [PATCH v2] tools/init-xenstore-domain: fix memory map for PVH stubdom Date: Tue, 12 Jul 2022 08:18:30 +0200 Message-Id: <20220712061830.20208-1-jgross@suse.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 In case of maxmem != memsize the E820 map of the PVH stubdom is wrong, as it is missing the RAM above memsize. Additionally the memory map should only specify the Xen special pages as reserved. Signed-off-by: Juergen Gross Reviewed-by: Anthony PERARD --- V2: - don't change mmio area settings (Anthony Perard) --- tools/helpers/init-xenstore-domain.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xenstore-domain.c index b4f3c65a8a..2d9ab6f1c5 100644 --- a/tools/helpers/init-xenstore-domain.c +++ b/tools/helpers/init-xenstore-domain.c @@ -71,8 +71,9 @@ static int build(xc_interface *xch) char cmdline[512]; int rv, xs_fd; struct xc_dom_image *dom = NULL; - int limit_kb = (maxmem ? : (memory + 1)) * 1024; + int limit_kb = (maxmem ? : memory) * 1024 + X86_HVM_NR_SPECIAL_PAGES * 4; uint64_t mem_size = MB(memory); + uint64_t max_size = MB(maxmem ? : memory); struct e820entry e820[3]; struct xen_domctl_createdomain config = { .ssidref = SECINITSID_DOMU, @@ -165,13 +166,16 @@ static int build(xc_interface *xch) dom->mmio_start = LAPIC_BASE_ADDRESS; dom->max_vcpus = 1; e820[0].addr = 0; - e820[0].size = dom->lowmem_end; + e820[0].size = (max_size > LAPIC_BASE_ADDRESS) ? + LAPIC_BASE_ADDRESS : max_size; e820[0].type = E820_RAM; - e820[1].addr = LAPIC_BASE_ADDRESS; - e820[1].size = dom->mmio_size; + e820[1].addr = (X86_HVM_END_SPECIAL_REGION - + X86_HVM_NR_SPECIAL_PAGES) << XC_PAGE_SHIFT; + e820[1].size = X86_HVM_NR_SPECIAL_PAGES << XC_PAGE_SHIFT; e820[1].type = E820_RESERVED; e820[2].addr = GB(4); - e820[2].size = dom->highmem_end - GB(4); + e820[2].size = (max_size > LAPIC_BASE_ADDRESS) ? + max_size - LAPIC_BASE_ADDRESS : 0; e820[2].type = E820_RAM; }