Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp367764lqr; Wed, 5 Jun 2024 08:19:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWwW57dVjvTd8i20g9+Zq8VGO5sJNCz2vIsnE6Dq4TS/HUjMxdGszqOr6Vq2anl39f0qVzCf+vyXsnRq8H+n06R+MamOyZGd9KkmHqevQ== X-Google-Smtp-Source: AGHT+IG0dLryZ01ICjeV/4jFXeGADnifQhcoe807uOPx3T8kafEG3OQzWbkA9/BZiCtgV+n+8NCr X-Received: by 2002:a50:aa93:0:b0:57a:27f5:1272 with SMTP id 4fb4d7f45d1cf-57a8b6b709fmr1899399a12.24.1717600779291; Wed, 05 Jun 2024 08:19:39 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31c62f55si6279407a12.299.2024.06.05.08.19.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 08:19:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202810-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=2JTuK3j1; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-202810-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202810-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.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 am.mirrors.kernel.org (Postfix) with ESMTPS id CFE151F23922 for ; Wed, 5 Jun 2024 15:19:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 784754D5A0; Wed, 5 Jun 2024 15:19:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="2JTuK3j1" Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2066.outbound.protection.outlook.com [40.107.101.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E606E3FB9F for ; Wed, 5 Jun 2024 15:19:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.66 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717600761; cv=fail; b=nw5uvKVxtQPsaAMf0ikvCUIokxJRU1JzxSzvgp0LSYBvRFJMfqaaCv1i5ZLTwaRCX/IuA6h46EbisRIBlYOzOldVtdmmoxLhILbq/+hh7XkTYamPNQYDw1WyO1oMwqxy1ivvSwtF+HjtwcQ6kkdLXp7JiwB5dgdTMd7nWBd9OT0= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717600761; c=relaxed/simple; bh=IavZdyRsGZrMrbowDBZRv1TxGG6Bz6Lt7A/t6mgnRj0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KKQJlodx89gq/BrbN7Q//MlQzuxgdivLYP/OLvrCFaJLBrTknwjA/LdTVvmly2K7IWKZohnkjuUeHFVWqigMscHmDN93v2v7/KZjF1AKRd3KgJYjvvo2dBy2YSwI1HRrOXp89hTyvWaSvEb1/rmNJz2epzTunU9eEHQVCxK8OBo= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=2JTuK3j1; arc=fail smtp.client-ip=40.107.101.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cXPmMb9BO6eouaKyfakSrV8J1Vu7SiPYisqsc8YDz79PVqX/w+DwlKZ2JwUo3oPm/CB0usEWTjzGPr4EABEXb3t5BBpnzRs3zP0oU0YAlgWF3lJi39TOy3yOv+YZOTEWS72d0+Ag8Fv8wGaseyMfrNvAEYraMCqWJdTQ+dobOBT7kF26Frk/WEXe9MU/iVI6v9fsloQpLL6wgAFJcV+0vvz2yxs0hSlsO8M68jMw+DGrT4Yf6isDttJHZy0rE4qxlAVMI4bBK1rkiim9SQaQg0m4amh56JcnowEm36x003v2eoNzBo5WatLylXMkhTUnZ9Hb9OJwpeInpJZu5J4cHw== 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=97CFRtmVneyhtbBwUcNnRcQCwWEYI0vvcRSrjMKjYnU=; b=RL3I11aNUIGxICi9by/BaBJ2RRKgqK1kvc2pxTBBNefIq6wj1UI75wAALCN+aDhd0u60pr5f4LA4DTrM276awQSfToNh2uiaiRJbtzi+hoLOe9Xc8cVN84NYUG/JqM3egIjpKZs/zGiciqC80hhd5rZmqcLY/4ZWtmRTiuaicRlIyROBJgRU2b2xasMbG2/+asYBtaUduEhX5uppiR0A+HSOTXLZOp5vHcBOk1UYVHKAVgRoIx/WdEu6y1WiXZRxZ58jRSe/aHfUsGJ2R0E9i4vtpUfD1xCr6vv6Uo9CVyOdW71Qa4E1O79N//0i3yiuw3FzK63vVVB8gUTwbt8nqg== 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 (0) 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=97CFRtmVneyhtbBwUcNnRcQCwWEYI0vvcRSrjMKjYnU=; b=2JTuK3j1eYjgwGUBLSZ8dxf81huqo1ddvGQb6cIJluZ6hCtQukDQwR9gHAuedeXaAr2E3MZhVsI9YXN5axYlP+XYqkoVNjz8FKNKXs0hwPKV1nDXUj8lEQ+f2/KU/mcn7hZoAUcXS8z4OtJox7uNTOV/y6iu6NHUfFCnscv4Dwo= Received: from CH2PR07CA0046.namprd07.prod.outlook.com (2603:10b6:610:5b::20) by LV8PR12MB9336.namprd12.prod.outlook.com (2603:10b6:408:208::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.20; Wed, 5 Jun 2024 15:19:16 +0000 Received: from CH1PEPF0000A346.namprd04.prod.outlook.com (2603:10b6:610:5b:cafe::cf) by CH2PR07CA0046.outlook.office365.com (2603:10b6:610:5b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.31 via Frontend Transport; Wed, 5 Jun 2024 15:19:16 +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 CH1PEPF0000A346.mail.protection.outlook.com (10.167.244.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Wed, 5 Jun 2024 15:19:16 +0000 Received: from tlendack-t1.amd.com (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.2507.35; Wed, 5 Jun 2024 10:19:14 -0500 From: Tom Lendacky To: , , , CC: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Andy Lutomirski , "Peter Zijlstra" , Dan Williams , Michael Roth , Ashish Kalra Subject: [PATCH v5 01/13] x86/irqflags: Provide native versions of the local_irq_save()/restore() Date: Wed, 5 Jun 2024 10:18:44 -0500 Message-ID: X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: CH1PEPF0000A346:EE_|LV8PR12MB9336:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d2fc1e3-934e-4fa1-e3e9-08dc8572dd55 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|82310400017|36860700004|7416005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?qj3/CI2mdRq/ILwJYwnHQVR632YRlgmYKysFDTxWoQz/HRt1bbmgyHwVj1td?= =?us-ascii?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45CUYYIkWp53Kx0hJQ9b6JoJAI+Pf?= =?us-ascii?Q?U8I9wc/i7kjc2kmxT98fui7UxMfcG+EI1EM6WYdwFc/UGh4U5tsglgci4jrQ?= =?us-ascii?Q?9QJT/k3eOI/FborqDgKy1FdYn/PDOas2ryx2BTvrWN3L33XOnOAPj0RYxPwU?= =?us-ascii?Q?DbtKdIZH+NY8VF/j24/ebLZjai4agub9qrpAit84QE5+xKgOSu11Az8WtH8q?= =?us-ascii?Q?cs/9W5vfDZw3EHftUMtq7VsgQidRbGod4Ymf6siqOncLtGEepuzNLDyWrvhn?= =?us-ascii?Q?Lf6dXIxOrRvH3y7pHxJhqKxf+6RxeSZrVVOuXH25jJ3qZ5+Mougm67jB8kvw?= =?us-ascii?Q?x+ZEGWVF1Ejq2/Qcq7G8Xdkva+o6ziPMYNe92vAP2uDrzTJUNl+mUw5J9U8y?= =?us-ascii?Q?kRXH7PfOHtbC3tDKqXqyXysR5XsWck4ivdZUBjTUtEdEbwRFvb00ow31nIdt?= =?us-ascii?Q?0LSENhIAn2DVzilbV6QjLwcm30XEE7+GraPxcnNfJW45ub/BTg=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(376005)(82310400017)(36860700004)(7416005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2024 15:19:16.5146 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8d2fc1e3-934e-4fa1-e3e9-08dc8572dd55 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: CH1PEPF0000A346.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9336 Functions that need to disable IRQs, but are common to both early boot and post-boot execution, are unable to deal with paravirt support associated with local_irq_save() and local_irq_restore(). Create native versions of these for use in these situations. Signed-off-by: Tom Lendacky --- arch/x86/include/asm/irqflags.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h index 8c5ae649d2df..cf7fc2b8e3ce 100644 --- a/arch/x86/include/asm/irqflags.h +++ b/arch/x86/include/asm/irqflags.h @@ -54,6 +54,26 @@ static __always_inline void native_halt(void) asm volatile("hlt": : :"memory"); } +static __always_inline int native_irqs_disabled_flags(unsigned long flags) +{ + return !(flags & X86_EFLAGS_IF); +} + +static __always_inline unsigned long native_local_irq_save(void) +{ + unsigned long flags = native_save_fl(); + + native_irq_disable(); + + return flags; +} + +static __always_inline void native_local_irq_restore(unsigned long flags) +{ + if (!native_irqs_disabled_flags(flags)) + native_irq_enable(); +} + #endif #ifdef CONFIG_PARAVIRT_XXL -- 2.43.2