From patchwork Wed Dec 14 19:40:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13073389 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84212C4332F for ; Wed, 14 Dec 2022 19:50:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1FBDC8E0006; Wed, 14 Dec 2022 14:50:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1AC378E0002; Wed, 14 Dec 2022 14:50:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0259A8E0006; Wed, 14 Dec 2022 14:49:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E3F4B8E0002 for ; Wed, 14 Dec 2022 14:49:59 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B6A59160458 for ; Wed, 14 Dec 2022 19:49:59 +0000 (UTC) X-FDA: 80241952518.11.1DBE2D0 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2077.outbound.protection.outlook.com [40.107.101.77]) by imf18.hostedemail.com (Postfix) with ESMTP id F14C61C0005 for ; Wed, 14 Dec 2022 19:49:56 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=x7m2MRCb; spf=pass (imf18.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.101.77 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671047397; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jm/QvkaIBQJRPPdHWTGEkZBgJM39n0PSJvku/UCbtsA=; b=fZwozRTuXLVEH95ZQN7g3VL4/FyHzorIUVXL4U1RaZi3126DKOSaXzDCJITpMdeoO/unzn fsmsPe2XTr2M8TPjAHJ0vcmXMfT1JHWATxv60Dc0w2M/cqOw7lc840NEHp6o5GEsZwqzG0 3JRQ04IDKXdG41aG/0YNZckgM0l70cY= ARC-Authentication-Results: i=2; imf18.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=x7m2MRCb; spf=pass (imf18.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.101.77 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1671047397; a=rsa-sha256; cv=pass; b=mHHH4pPjWtQPZi/Ub94dwWSk3paYRE465TUv99ZQQGDCCHwyIsTeC5QdBzcmEBz7HDfZ5B 7cnKAZe5CcgPkBeLFYZdIWsaWkRbBJhbS0X7L4RogyvWWJaI9L2XK+El+2x/vg5Q25gwOW ZJKki7aE9JMyTjEqY7mHKWD1xK6Sv/Y= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L/LHjBRAMWE7Lluf8M+RSyU4G3tTIiiKGpHXME25PsJjAxxAfqrptMWwFCEaRWb+lzrOFLCPpibBSCqBBNmfDDXqX1e/ficS/Pa6HdDShKKnRYOwFKKy/wfszeLsIccUDyok0s7wHLKqdjFatI457l4Nxg1xqNTgrPJvxDRonXZwe9vT8czldIWSZRYJJFSeC63f8d3nKKh0ohab+QaSHtCokOWG38kbAxI+BOk39tyCen8OUkuZc747afTv9jthxrBJjIYR7o4ey29obfQPVDR02jCr6SoE7EY6wFdNCmkeToI0Nnp7GLhFytqdUkZ63QDx1iandGcaQ2EZjCWhLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jm/QvkaIBQJRPPdHWTGEkZBgJM39n0PSJvku/UCbtsA=; b=LXEOcEZG3dDf92gTed/skioinXqZi/uF9Eq7IklSjgF6hYfiKAG8YwEWKqYCuJygDAL9f9PNmZVGagVfH35L32ip9aJuByo8KNMbyn1QfzKM1hb2hB9GECBrjK5jStnnvcZLWjci8mfvwpkPJI5RZl0AmKfVCv31WpmyxPjkrb9pZoJ8aVKFTZ/CdrR7rkhgjLwjKwF8jU/ycge2bnpP1Pflb/noDXgdO2xGEBqZue7PQErlxjVZEfmez4+4jkxrLs8PnHqKOvjU1hJOsH8RpF561wYyFOTwWIwXudJi/AQqa3OgD+Orr4tPmEKCU/r2ffHBEVA2wt9YTbucAOKkCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jm/QvkaIBQJRPPdHWTGEkZBgJM39n0PSJvku/UCbtsA=; b=x7m2MRCb66MyUjKw6o/WG2MwE2QHXiQ2tWRgBPOvo1A3MuyaoXDA1Dl6yymCpEeGa71RPzsN+3qP93P2cC3Og7GbgaKvEEzNWstWpETClCGyxntCytb7nA0zWOq6k8FSzl7BU8AL1LQbZ8HS5IOoje/Z9xcs5ROu9cAaCgsdSio= Received: from CY5P221CA0019.NAMP221.PROD.OUTLOOK.COM (2603:10b6:930:b::32) by CH2PR12MB4104.namprd12.prod.outlook.com (2603:10b6:610:a4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Wed, 14 Dec 2022 19:49:53 +0000 Received: from CY4PEPF0000C978.namprd02.prod.outlook.com (2603:10b6:930:b:cafe::c0) by CY5P221CA0019.outlook.office365.com (2603:10b6:930:b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.11 via Frontend Transport; Wed, 14 Dec 2022 19:49:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000C978.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5924.10 via Frontend Transport; Wed, 14 Dec 2022 19:49:53 +0000 Received: from localhost (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 14 Dec 2022 13:49:52 -0600 From: Michael Roth To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH RFC v7 17/64] x86/mm/pat: Introduce set_memory_p Date: Wed, 14 Dec 2022 13:40:09 -0600 Message-ID: <20221214194056.161492-18-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221214194056.161492-1-michael.roth@amd.com> References: <20221214194056.161492-1-michael.roth@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000C978:EE_|CH2PR12MB4104:EE_ X-MS-Office365-Filtering-Correlation-Id: ac7eaa51-59c2-46ad-9f35-08dade0c5e8e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G0jRK5W87/t82xBZlSDAkg18bzwSFG7FYgZLG/T1zrXjVNB+ednlSNn0dR0/u3N4qtpPcORWfFV9QVhbccKnmenjaTxx+y47V1XWhKhsgI6WGlmSWqURYIQ+hqYMAv7YUIE+uS3oLNAl+Zk7+lS7X2lSrgXoge5FNWlaN6xiw2SAqoyJR82AEJo7A7gVGDl0dTza6cfF41kM5a1ulFX4KVt19CT9raMzmG3F2lI/J0GHGRnBRt7B7EkGJi7COm4OoAyiWL7epESO/e6XBB+x+jfjMW5TW1YHxU69NbmjUnS9YtYXg6DbsopyZ7CssBatdWZgYhmK3VAiRpva0wZUshx4UQ0swuksNK9Z5ZN2gD7TcDPZLpvUa03BynV7wP00dyR+aLFAh8pym6DAk36gIt1SRcsfOKUl4gI29n/Ako8YN/o7HLc0lbMLvJlMLK+TL2WDan6ZOFjCRnBpfoTF85jSCW7gmKDqaZXmYVQDWjSVrdEqCIcWnixApKvueIH+8JXUJxkssMX08SwNSRbLvrVzac3kgobMN8vocsRBrNQwsYWAxupTJqiq8nZiBdq0lykn6eIXePTXbVlsSQRGA3x47B1kA0MvzHxjI3mGl70clFiGtTZbl8LF1apiGxSpn/Og1NVE2ELvyTbcPdmpJuBnOOk8oeYTw4EydFjXAB/HMtNxDQ4OTIxeMPbg4MhlbYNJKRy0ss+gVuUsvjrolPOja4pQqfSYVIDzZlerF5o= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:CA;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(39860400002)(136003)(396003)(451199015)(36840700001)(40470700004)(46966006)(2616005)(83380400001)(336012)(41300700001)(8676002)(2906002)(16526019)(1076003)(5660300002)(7416002)(8936002)(7406005)(36860700001)(36756003)(426003)(82310400005)(40460700003)(47076005)(81166007)(44832011)(356005)(82740400003)(40480700001)(6666004)(6916009)(54906003)(70586007)(4326008)(478600001)(316002)(70206006)(26005)(86362001)(186003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2022 19:49:53.2475 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac7eaa51-59c2-46ad-9f35-08dade0c5e8e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000C978.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4104 X-Stat-Signature: gdh3kg8sftjfwqqyqsjhqs15amm8qi4w X-Rspam-User: X-Rspamd-Queue-Id: F14C61C0005 X-Rspamd-Server: rspam06 X-HE-Tag: 1671047396-46832 X-HE-Meta: U2FsdGVkX192cv91HKBiA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-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Ashish Kalra set_memory_p() provides a way to change atributes of a memory range to be marked as present. Signed-off-by: Ashish Kalra Signed-off-by: Michael Roth --- arch/x86/include/asm/set_memory.h | 3 ++- arch/x86/mm/pat/set_memory.c | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/set_memory.h b/arch/x86/include/asm/set_memory.h index b45c4d27fd46..56be492eb2d1 100644 --- a/arch/x86/include/asm/set_memory.h +++ b/arch/x86/include/asm/set_memory.h @@ -12,7 +12,7 @@ * Cacheability : UnCached, WriteCombining, WriteThrough, WriteBack * Executability : eXecutable, NoteXecutable * Read/Write : ReadOnly, ReadWrite - * Presence : NotPresent + * Presence : NotPresent, Present * Encryption : Encrypted, Decrypted * * Within a category, the attributes are mutually exclusive. @@ -44,6 +44,7 @@ int set_memory_uc(unsigned long addr, int numpages); int set_memory_wc(unsigned long addr, int numpages); int set_memory_wb(unsigned long addr, int numpages); int set_memory_np(unsigned long addr, int numpages); +int set_memory_p(unsigned long addr, int numpages); int set_memory_4k(unsigned long addr, int numpages); int set_memory_encrypted(unsigned long addr, int numpages); int set_memory_decrypted(unsigned long addr, int numpages); diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index 2e5a045731de..b1f79062c4a5 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -1993,17 +1993,12 @@ int set_mce_nospec(unsigned long pfn) return rc; } -static int set_memory_p(unsigned long *addr, int numpages) -{ - return change_page_attr_set(addr, numpages, __pgprot(_PAGE_PRESENT), 0); -} - /* Restore full speculative operation to the pfn. */ int clear_mce_nospec(unsigned long pfn) { unsigned long addr = (unsigned long) pfn_to_kaddr(pfn); - return set_memory_p(&addr, 1); + return set_memory_p(addr, 1); } EXPORT_SYMBOL_GPL(clear_mce_nospec); #endif /* CONFIG_X86_64 */ @@ -2039,6 +2034,11 @@ int set_memory_np(unsigned long addr, int numpages) return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_PRESENT), 0); } +int set_memory_p(unsigned long addr, int numpages) +{ + return change_page_attr_set(&addr, numpages, __pgprot(_PAGE_PRESENT), 0); +} + int set_memory_np_noalias(unsigned long addr, int numpages) { int cpa_flags = CPA_NO_CHECK_ALIAS;