Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp666142ybg; Tue, 28 Jul 2020 15:58:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJvrkMkGNw5fnA+wyZcOR/MeaPWpEGDDnJIdNphmX+S3zeBlzbTh3EUCWvywiOcXfUdJJZ X-Received: by 2002:aa7:c70b:: with SMTP id i11mr8792531edq.272.1595977096826; Tue, 28 Jul 2020 15:58:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595977096; cv=none; d=google.com; s=arc-20160816; b=lxv9nWsYmpdgHSE1iP2Ze0FjyccR+n+CIG7EOzAItxKmXmjvUuOMS5CYpkyp+/W5bL h4VsSQLVa9fkhAb2DEKJs1AtgXEfg2jMRb1NgTKGo+hWkwxORnyDqaRM7Dph/ZYgklMd J7Ht8gGzSiGLMgE2nHsRnSGDeOWxRFiBremZeamgp2GSHi66Bzd6lL5QUgJ2Z+Ffy5NI 9jlLmfdAb20RchXjWZuT+otj/KORsStSoHKPMkm3X2TzXqCJCTNFS85CaurcrtsoxAwV GlULDE9rntD+Ok/9nO2MqfP/ivrf3GQpsyLDohfgv6662275P0R0xfBw+KRcD/lViEDL Ym6Q== 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=zGrAc382g2MbcGesk1KGEJOXCh/rORh/jxXTBYyLCoc=; b=ptufG+yrbUq6tGmY+P3WHoznInH+ZK+EXwOE3ainAWx7BDRXUfF6wVJ9Ndg5prx2YY 9eRDcPCG7oodEND+kPmzea02OWMOXT+toOkwrxeaVUEWUSsDG5rCcBPjNBjcYS9TFVEj czgJxnHm+Y6xhwMKx9W1UHs0ccNKJocXkZkqMpdI/ajO2wdIX2VVqJAin6DSqkjOaquO q2o8ALzq/glUnBOR4Z/jC1AtG2R3JWHNWcnLVE8nFMSX4oORczN9JtE4J5B1h7rF7zp7 ocOMZEd2cqdg2HlbszRRLua5Fmb63zfwC4C1FlMx7w9UCYsC261UStljTvij2GnxMHsR 4ISg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bw25si295ejb.10.2020.07.28.15.57.54; Tue, 28 Jul 2020 15:58:16 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730062AbgG1W5j (ORCPT + 99 others); Tue, 28 Jul 2020 18:57:39 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:45944 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729937AbgG1W5a (ORCPT ); Tue, 28 Jul 2020 18:57:30 -0400 Received: by mail-qk1-f195.google.com with SMTP id u64so20414198qka.12 for ; Tue, 28 Jul 2020 15:57:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zGrAc382g2MbcGesk1KGEJOXCh/rORh/jxXTBYyLCoc=; b=klitusfgth6p6XAJQJeGXrqPyrSFVHRyAHARVFzFRyl7AWSIu3URLdcdF1YSCZ6j/N 9sZkIxemWsDiX3nRpwho21imiSgI8uEMQYfd6lAKtY25kLeJIBN35md4QLur/FyYdYSm In1s1sfYdFDcM0C7m7/m6Ay1FNOP818YDMEh0Bgx8HC94w5uTzfLnISPv8g/H4iawStN jfD5tLyaM6aLl4NZk4ho5ovsB3T76RHfLyr5fjT4+he1709HgT58HXabzv7xhkLdpaTM qKLzxMEpk1+I5c6MB2AW9l1FCpGkQNvj5dHzdqDWsYmUmKeTTqPrESiX2NwNdbnU8iBR gP2Q== X-Gm-Message-State: AOAM531iztM+F24GafmTihkwxP2JOnqw2gXXdmGlo6cUxFi9e+fnvSlq gqloFl8NHJifqQd7WYuUWb8= X-Received: by 2002:a37:4884:: with SMTP id v126mr29006721qka.118.1595977049163; Tue, 28 Jul 2020 15:57:29 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id o187sm88118qkd.112.2020.07.28.15.57.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 15:57:28 -0700 (PDT) From: Arvind Sankar To: Kees Cook , x86@kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH v3 07/21] x86/kaslr: Eliminate start_orig from __process_mem_region Date: Tue, 28 Jul 2020 18:57:08 -0400 Message-Id: <20200728225722.67457-8-nivedita@alum.mit.edu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200727230801.3468620-1-nivedita@alum.mit.edu> References: <20200727230801.3468620-1-nivedita@alum.mit.edu> 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 Set the region.size within the loop, which removes the need for start_orig. Signed-off-by: Arvind Sankar --- arch/x86/boot/compressed/kaslr.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index f2454eef5790..e978c3508814 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -623,7 +623,7 @@ static void __process_mem_region(struct mem_vector *entry, unsigned long image_size) { struct mem_vector region, overlap; - unsigned long start_orig, end; + unsigned long end; /* Ignore entries entirely below our minimum. */ if (entry->start + entry->size < minimum) @@ -635,12 +635,9 @@ static void __process_mem_region(struct mem_vector *entry, return; region.start = entry->start; - region.size = end - entry->start; /* Give up if slot area array is full. */ while (slot_area_index < MAX_SLOT_AREA) { - start_orig = region.start; - /* Potentially raise address to minimum location. */ if (region.start < minimum) region.start = minimum; @@ -653,7 +650,7 @@ static void __process_mem_region(struct mem_vector *entry, return; /* Reduce size by any delta from the original address. */ - region.size -= region.start - start_orig; + region.size = end - region.start; /* Return if region can't contain decompressed kernel */ if (region.size < image_size) @@ -679,7 +676,6 @@ static void __process_mem_region(struct mem_vector *entry, return; /* Clip off the overlapping region and start over. */ - region.size -= overlap.start - region.start + overlap.size; region.start = overlap.start + overlap.size; } } -- 2.26.2