Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp214459lql; Fri, 12 Apr 2024 08:17:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUbYChHmseh6F7auiGNzy7o20iHH8gXTFDJ32dCF1HKgGZkeRqZKHBjeByaafs/eZl4GVPcqHm01mAD8HKq4Wjvha+1h/QlnZwfEVEaUA== X-Google-Smtp-Source: AGHT+IGjMSA1jQDfiRHNJs7cmi0UCPvtErnWwkpef0S9RQIQ22X43RRLxMIXdnktCGIWrJ+1vkvO X-Received: by 2002:a17:902:ce87:b0:1e4:31e9:83ba with SMTP id f7-20020a170902ce8700b001e431e983bamr3073061plg.1.1712935028120; Fri, 12 Apr 2024 08:17:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712935028; cv=pass; d=google.com; s=arc-20160816; b=w26NN0TA9j+cOJseTujUyzRUXrT7UvEd+2J4L38kYZmlMsAM87/7HkGLk6WKqimQc+ Qb9QqxCYXkkVrhqXuYgNj5zkUvKnDvQ+buXUumQV8UsV43qkQ1Lb42LhDE5wgzmTahiB DvX0UA1cXTTT9qiqHFdvSbtkmIMisBMJzhZ8DGZP4ilO70ZvOxzBqDJV7tm2zzdVlPTo r1WyxeD0H2OueP06bv6SiBw32CNlm6gZiG+/+iDYB017B9AwpwcK/GHPUlaJ2txcV+kY Kf0x8KARVEhqavj+NxE6HcXl0B+75y+HarMGfE0ijJQiJ8VcwuLQhoBqReukUlxlGoif OcXg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature; bh=MhbYkWyAf/ESm4SmbTrhfHb/LUX43QTDKtnj/G5DytA=; fh=US9T5DQVpSqdS5IsWUkzvyQ/8hm9p9evM4Fp6mhU8dw=; b=gnfOIdjOhBrQ9qzM6AqEN/OjHJp229nYSG1HRQ0OAMW33rJ9CjfUyuUGRqLlps3sm7 lp3kUe8AEjj7AJqf93t5s40w+8trLiAZQSUu0tBaKDtskeBJIJB+/hVcUUPzNZKb/uQs QE/YK7ZdEwfN22ghbbi09Ujr1CTtKG7OprXL+FBbqr+LYewh5XLJLkX9GpbcbYMK7bPy I3VGR/zswgUFOCYX5yWHLp/oYuf9cBaKOimj4z+BGhAjbT6R7D8jRMdFUpFmWq3SqNrS aAQQxMFElYih46OkXN3wuObFIeBLmCFKjCJ2a93hjQvgWP1EHuOW82+9o7nQDEzeDEUS Ogvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Aip4F99a; dkim=pass header.i=@suse.com header.s=susede1 header.b=Aip4F99a; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-142918-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142918-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k18-20020a170902c41200b001e205782c0dsi3421852plk.426.2024.04.12.08.17.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 08:17:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142918-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Aip4F99a; dkim=pass header.i=@suse.com header.s=susede1 header.b=Aip4F99a; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-142918-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142918-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B6324284359 for ; Fri, 12 Apr 2024 15:17:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CEBC914D2B1; Fri, 12 Apr 2024 15:13:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="Aip4F99a"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="Aip4F99a" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48DEE14B075 for ; Fri, 12 Apr 2024 15:13:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712934812; cv=none; b=eqGbGOjKkgbPpW91RhbsaMsy5dIOJLjV5aOSAIJSiA/a27mxce4SMz7S+K82snZblq1PzLP4mAAkYthTbUY8uXLE5qFXgC/ly1RnVSXUaEJoM3TVqPB2L3k1f9pOwz0SIyINEUwJa8vl873oJ1WanfAHeyHy/Tqeoy/m/Ph2kpU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712934812; c=relaxed/simple; bh=4fuc3osJ0CBfJf2wQwqPRjCvOxcrZi0VVEyxaNwFjus=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=R7HVZh/miAwWXDwEVNrxMLGGAnDBs2Y0wBd+Zi1yh97YlXfcKxcbZyOuzbtPQGDV6KmxJnW4agpNLtpsyjGOlBBwdqpeTSOAPY5dcG5d5aOeQ3D9sj1QJFrRaUoJt7RSVPn5S+9CCoIYwpj0IkKKzTSj7+gaD5qcFQBAUQ4l6FI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=Aip4F99a; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=Aip4F99a; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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-out2.suse.de (Postfix) with ESMTPS id 859DE5FE6A; Fri, 12 Apr 2024 15:13:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1712934808; 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=MhbYkWyAf/ESm4SmbTrhfHb/LUX43QTDKtnj/G5DytA=; b=Aip4F99a4oJMUIZ6HReisZ2YSUbFppIqWt6Fga7A5bPQsK83oNwMNhwa0cxFParhGiMIvk u6ADHILCKujpTml+n6DR6jR+B6UJUYQyiFWeeXnZBSzZv2qbxcze5djgV93Skt8fMk8Opz VzkEDgw+kGKPIWBe6FVOwD1QOIiosuk= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1712934808; 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=MhbYkWyAf/ESm4SmbTrhfHb/LUX43QTDKtnj/G5DytA=; b=Aip4F99a4oJMUIZ6HReisZ2YSUbFppIqWt6Fga7A5bPQsK83oNwMNhwa0cxFParhGiMIvk u6ADHILCKujpTml+n6DR6jR+B6UJUYQyiFWeeXnZBSzZv2qbxcze5djgV93Skt8fMk8Opz VzkEDgw+kGKPIWBe6FVOwD1QOIiosuk= 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 847541368B; Fri, 12 Apr 2024 15:13:25 +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 mh/yF5VPGWa4AQAAD6G6ig (envelope-from ); Fri, 12 Apr 2024 15:13:25 +0000 From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Juergen Gross , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" Subject: [PATCH v2 3/4] x86/pat: restructure _lookup_address_cpa() Date: Fri, 12 Apr 2024 17:12:57 +0200 Message-Id: <20240412151258.9171-4-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240412151258.9171-1-jgross@suse.com> References: <20240412151258.9171-1-jgross@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Flag: NO X-Spam-Score: 0.19 X-Spam-Level: X-Spamd-Result: default: False [0.19 / 50.00]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; BAYES_HAM(-0.01)[46.79%]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_SEVEN(0.00)[10]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.com:email] Modify _lookup_address_cpa() to no longer use lookup_address(), but only lookup_address_in_pgd(). This is done in preparation of using lookup_address_in_pgd_attr(). No functional change intended. Signed-off-by: Juergen Gross --- V2: - split off from V1 patch (Ingo Molnar) --- arch/x86/mm/pat/set_memory.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index bfa0aae45d48..4ebccaf29bf2 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -744,11 +744,14 @@ EXPORT_SYMBOL_GPL(lookup_address); static pte_t *_lookup_address_cpa(struct cpa_data *cpa, unsigned long address, unsigned int *level) { - if (cpa->pgd) - return lookup_address_in_pgd(cpa->pgd + pgd_index(address), - address, level); + pgd_t *pgd; + + if (!cpa->pgd) + pgd = pgd_offset_k(address); + else + pgd = cpa->pgd + pgd_index(address); - return lookup_address(address, level); + return lookup_address_in_pgd(pgd, address, level); } /* -- 2.35.3