Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1706139ybh; Tue, 14 Jul 2020 05:20:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQ1ZBThJWFJ7xOqUz/QxI0pewU/KDhoVCq16PuEhAMBAO1j+Gq2f1FMeIePUZVBUahSVcQ X-Received: by 2002:a17:906:69d3:: with SMTP id g19mr4395783ejs.402.1594729211612; Tue, 14 Jul 2020 05:20:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594729211; cv=none; d=google.com; s=arc-20160816; b=JLyVjtrIjcsLYBwpAdZUiuwDpPeei4i9AJIZ91VmaKim83iyh/4ftVil9cOr49NNTU zzOg76eT/nvrBSyMt8ea6SvHflOEELKdcKvNsbEGx7IoHyYw8kofnS5VWXwJMOgsGGQU S5vL74dw7kjGZo5tEJZQ/E1c6VyTbqY5k3zGmMc8vtJmoPAmOlftFXhgjItAsFoMtCug 5/3lDSR5ko9JCPOcIUhDBaECzrsHy284Pgm1vnspt+HRrrm6JY+qKuw8LbFxIk8r4dle HQyVb9V26LVrPa6Guor/Ug2hLS84rywxTDkOgoEU69naxTPKEFzBIzFvAkyEVNNvYkyG aGUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=AmZrypy6EgIqT9Fvc0ForpuWqP/O0DL0zAClsiNKndA=; b=AP/hR/VIWB1bRkxEeBPhDjqR7j/4Ii9DUvS0coQPGA39bCfezcLkObICplKaUZzgJE FrakoSOkpIt2yjD/i+LCznDF/XJylflmEGJmglixXFFBr7OOhQQFnJ8FH7sWTTZ5/Kxs JEJN6jyqKEh0++gv4WmjRH+Hi6ALwI3HSKY4AxW936AHC+XNznAuCgjKZTsKWtCmuOc8 a2h4Cwrj9bp2oR+CnFyKsAbYle06XApxrPgj5BXw8v8JDXznlC2nqw9XOcIQ6HgFPYeu D3LWiDcAaRQ7y073XteD6hz0Ed9YuM8DGRT6JEDwhq2KoIiSJ+YAu8n6MVJYDCD8mWNJ ronQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z11si10883791edr.395.2020.07.14.05.19.45; Tue, 14 Jul 2020 05:20:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728471AbgGNMQ6 (ORCPT + 99 others); Tue, 14 Jul 2020 08:16:58 -0400 Received: from 8bytes.org ([81.169.241.247]:53184 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728168AbgGNMKo (ORCPT ); Tue, 14 Jul 2020 08:10:44 -0400 Received: from cap.home.8bytes.org (p5b006776.dip0.t-ipconnect.de [91.0.103.118]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by theia.8bytes.org (Postfix) with ESMTPSA id 10C596B1; Tue, 14 Jul 2020 14:10:42 +0200 (CEST) From: Joerg Roedel To: x86@kernel.org Cc: Joerg Roedel , Joerg Roedel , hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , David Rientjes , Cfir Cohen , Erdem Aktas , Masami Hiramatsu , Mike Stunes , Sean Christopherson , Martin Radev , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH v4 17/75] x86/boot/compressed/64: Change add_identity_map() to take start and end Date: Tue, 14 Jul 2020 14:08:19 +0200 Message-Id: <20200714120917.11253-18-joro@8bytes.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200714120917.11253-1-joro@8bytes.org> References: <20200714120917.11253-1-joro@8bytes.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel Changing the function to take start and end as parameters instead of start and size simplifies the callers, which don't need to calculate the size if they already have start and end. Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/ident_map_64.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/arch/x86/boot/compressed/ident_map_64.c b/arch/x86/boot/compressed/ident_map_64.c index c63257bf8373..62e42c11a336 100644 --- a/arch/x86/boot/compressed/ident_map_64.c +++ b/arch/x86/boot/compressed/ident_map_64.c @@ -89,10 +89,8 @@ static struct x86_mapping_info mapping_info; /* * Adds the specified range to the identity mappings. */ -static void add_identity_map(unsigned long start, unsigned long size) +static void add_identity_map(unsigned long start, unsigned long end) { - unsigned long end = start + size; - /* Align boundary to 2M. */ start = round_down(start, PMD_SIZE); end = round_up(end, PMD_SIZE); @@ -107,8 +105,6 @@ static void add_identity_map(unsigned long start, unsigned long size) /* Locates and clears a region for a new top level page table. */ void initialize_identity_maps(void) { - unsigned long start, size; - /* If running as an SEV guest, the encryption mask is required. */ set_sev_encryption_mask(); @@ -155,9 +151,7 @@ void initialize_identity_maps(void) * New page-table is set up - map the kernel image and load it * into cr3. */ - start = (unsigned long)_head; - size = _end - _head; - add_identity_map(start, size); + add_identity_map((unsigned long)_head, (unsigned long)_end); write_cr3(top_level_pgt); } @@ -189,7 +183,8 @@ static void do_pf_error(const char *msg, unsigned long error_code, void do_boot_page_fault(struct pt_regs *regs, unsigned long error_code) { - unsigned long address = native_read_cr2(); + unsigned long address = native_read_cr2() & PMD_MASK; + unsigned long end = address + PMD_SIZE; /* * Check for unexpected error codes. Unexpected are: @@ -204,5 +199,5 @@ void do_boot_page_fault(struct pt_regs *regs, unsigned long error_code) * Error code is sane - now identity map the 2M region around * the faulting address. */ - add_identity_map(address & PMD_MASK, PMD_SIZE); + add_identity_map(address, end); } -- 2.27.0