Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp289859lqh; Mon, 6 May 2024 21:24:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVS6fuhVACzsseGCtqt8psmIDFQpSTtMIWskYVDdu3cu7LIU9/30izJG54/8zia+J5x94JMAP/MVvMNcX/oHViVRqB+z5GcLFf8VpOJHQ== X-Google-Smtp-Source: AGHT+IG7MhRImjpMWn/8fr8xws5rKs1RTpHBH4iVi5ciKh1XAnX7zRqYOHbNUhjTuOtwvhbM4O0g X-Received: by 2002:ac8:7c4f:0:b0:43a:b530:1790 with SMTP id o15-20020ac87c4f000000b0043ab5301790mr11955539qtv.58.1715055889109; Mon, 06 May 2024 21:24:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715055889; cv=pass; d=google.com; s=arc-20160816; b=sq1J0XsHei4zHqZSqNIa3dCraN8bW9GQ8GZnRh2uBtpM+6C7G/SrO2y23ElQAf2muq Qq/jnXxx0O9x/ZrjH91Qm33eyfNbDxtYR5LYI9/t8dQqn6tIgXWM7G/5AOExwtAZtbL9 tnFKHEBFBvVHVlGSdNIjtRL8UD3I0Ko0gpQ+KThr3/vNBjTXLQX3M+LyEaqBvieczXK7 joEdLL95S1P1J8XsrZ1k6OmwNY+3suXonoGtCwpA2kZdFJ7mssEixDBiyw3+B9FGdx/J tAb6sU8/7HWqBT6QwNZcAEtlI7MFHFERfX8FFy2iWXHJLwvdwWksAsC4QU6bCJo5lkfj hdug== 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; bh=z1Lw3P9YanIE686APl0ocJvc3j8wemnPI/GLUtJsD7M=; fh=c5EyvjmJK1xfp6JlxdjmXoRruy+xy0X17ywo/oxsYyc=; b=RupapH4lmFRSBu1xBxLyFd2f8l58bTsn7cNmnDnAuPA7tWkZ+16jWJ4m//czTXNKNi kVA2QAQP4AEnpdEQVG0ca3kD53EFHk2A0sahaqZywASrwUEkjPEKrJXdPYGOGn9d/uT3 1IsIWzVhQKE7Bi8RcZCryToKRJ3I+uvnhNILlJTJWqhaUgN3lSt8/FNW3TjaYPHeHW1L WSTQoQYKQ+DwgWu4n8INyTV2oVoKRsA56ypwDkcr25M/HKW97efGkRIOO0SCT72fsPxO sGE2TfXM14tjBBVPA8XTSBoPhOSYlRvWduhP3V+AbeDDloI3Jf3AV9FlNcIT15Xvw8yx apzA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="g+wD/fKP"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-170647-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170647-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id en5-20020a05622a540500b0043af8d3965bsi9885944qtb.807.2024.05.06.21.24.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 21:24:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170647-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="g+wD/fKP"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-170647-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170647-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C4DA11C22BF3 for ; Tue, 7 May 2024 04:24:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC0245490F; Tue, 7 May 2024 04:24:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="g+wD/fKP" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 6A4283FB9F for ; Tue, 7 May 2024 04:24:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715055869; cv=none; b=nvayyDBf3U2tj+mhBEmRvU6Qzgv1coodnI5KjFUNJjnNKRHx7E2XX5MGDmJ2pe+rz0sprCoqy0MDLXrXMZ5ieNKdED0RmSxIGctd0YmWmshi/e8vTbtwHbGhEhAw2Jhuki4QJEKZF9F/cERe7b44qYAY9WQ3tVaLpLYtObYMO/M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715055869; c=relaxed/simple; bh=15ZQOaIINVrYyckVff9nlHMAhbMUPetSUQ4uloRRNMg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lW3lkresbiRLE7qkrRFLKuYAqEcxKAhgzzJy8Uly/e2hKYFHSlAcbZdJtwlueMQoJ4BhrQMf3Kd7+qcAY7B6SogSHHFaiUFUXCNMcvyCw5bYx/hW39krsPMQCQ2i5Fsq4pyT+sfuf5rdB3yCrKtDZEca3pbPioXTIX/SG8PZZjs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=g+wD/fKP; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715055867; x=1746591867; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=15ZQOaIINVrYyckVff9nlHMAhbMUPetSUQ4uloRRNMg=; b=g+wD/fKPp3nnPIcaUGcQN/BkZbqdZuRfLesSvhvd6jfEukXzCLHJfzug nHo7ern0voRTkzh4J9dOfaPSuAxwkkj/9YcC/+xQ6nA/L5x/Rxb0CpvFo zRNclRmLvc2dOUq3dbvU7PijH/iKiCvUhUyDnZUvEx2X95JqmLBqYSiYh wOB+Y8Z9p4COpD7AnWQVddHuNFH8bDG0hKqBLW04+FogTm8ysD610lZtQ zqZzr900QY4jsUoxkx4YY/7s2JeWQPv/AER6gGl0WeUsPgqQzhyqQywR+ Tha3LdVBsAeZyMdznTUXwFvLEYmBH6hSMdJ+f1Mqj4ZrEl42lyjd5iqJx w==; X-CSE-ConnectionGUID: d42u2tRRS7+PdAUdofVlSQ== X-CSE-MsgGUID: fv9j6jYaQFGyVFtjwNOctA== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="22230760" X-IronPort-AV: E=Sophos;i="6.07,260,1708416000"; d="scan'208";a="22230760" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2024 21:24:26 -0700 X-CSE-ConnectionGUID: ZxnmY2sdTMmpIly6mXye6w== X-CSE-MsgGUID: k2aGazkCS4a7J2nMTp6wkg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,260,1708416000"; d="scan'208";a="33047166" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.212.193.196]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2024 21:24:26 -0700 From: alison.schofield@intel.com To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: Alison Schofield , "H. Peter Anvin" , "Kirill A. Shutemov" , Kai Huang , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] x86/pconfig: Remove unused MKTME pconfig code Date: Mon, 6 May 2024 21:24:22 -0700 Message-Id: <4ddff30d466785b4adb1400f0518783012835141.1715054189.git.alison.schofield@intel.com> X-Mailer: git-send-email 2.40.1 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 From: Alison Schofield Code supporting Intel PCONFIG targets was an early piece of enabling for MKTME (Multi-Key Total Memory Encryption). Since MKTME feature enablement did not follow into the kernel, remove the unused PCONFIG code. Signed-off-by: Alison Schofield Acked-by: Kirill A. Shutemov Acked-by: Kai Huang --- arch/x86/include/asm/intel_pconfig.h | 65 --------------------- arch/x86/kernel/cpu/Makefile | 2 +- arch/x86/kernel/cpu/intel_pconfig.c | 84 ---------------------------- 3 files changed, 1 insertion(+), 150 deletions(-) delete mode 100644 arch/x86/include/asm/intel_pconfig.h delete mode 100644 arch/x86/kernel/cpu/intel_pconfig.c diff --git a/arch/x86/include/asm/intel_pconfig.h b/arch/x86/include/asm/intel_pconfig.h deleted file mode 100644 index 994638ef171b..000000000000 --- a/arch/x86/include/asm/intel_pconfig.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef _ASM_X86_INTEL_PCONFIG_H -#define _ASM_X86_INTEL_PCONFIG_H - -#include -#include - -enum pconfig_target { - INVALID_TARGET = 0, - MKTME_TARGET = 1, - PCONFIG_TARGET_NR -}; - -int pconfig_target_supported(enum pconfig_target target); - -enum pconfig_leaf { - MKTME_KEY_PROGRAM = 0, - PCONFIG_LEAF_INVALID, -}; - -#define PCONFIG ".byte 0x0f, 0x01, 0xc5" - -/* Defines and structure for MKTME_KEY_PROGRAM of PCONFIG instruction */ - -/* mktme_key_program::keyid_ctrl COMMAND, bits [7:0] */ -#define MKTME_KEYID_SET_KEY_DIRECT 0 -#define MKTME_KEYID_SET_KEY_RANDOM 1 -#define MKTME_KEYID_CLEAR_KEY 2 -#define MKTME_KEYID_NO_ENCRYPT 3 - -/* mktme_key_program::keyid_ctrl ENC_ALG, bits [23:8] */ -#define MKTME_AES_XTS_128 (1 << 8) - -/* Return codes from the PCONFIG MKTME_KEY_PROGRAM */ -#define MKTME_PROG_SUCCESS 0 -#define MKTME_INVALID_PROG_CMD 1 -#define MKTME_ENTROPY_ERROR 2 -#define MKTME_INVALID_KEYID 3 -#define MKTME_INVALID_ENC_ALG 4 -#define MKTME_DEVICE_BUSY 5 - -/* Hardware requires the structure to be 256 byte aligned. Otherwise #GP(0). */ -struct mktme_key_program { - u16 keyid; - u32 keyid_ctrl; - u8 __rsvd[58]; - u8 key_field_1[64]; - u8 key_field_2[64]; -} __packed __aligned(256); - -static inline int mktme_key_program(struct mktme_key_program *key_program) -{ - unsigned long rax = MKTME_KEY_PROGRAM; - - if (!pconfig_target_supported(MKTME_TARGET)) - return -ENXIO; - - asm volatile(PCONFIG - : "=a" (rax), "=b" (key_program) - : "0" (rax), "1" (key_program) - : "memory", "cc"); - - return rax; -} - -#endif /* _ASM_X86_INTEL_PCONFIG_H */ diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile index eb4dbcdf41f1..ecd78a61da2e 100644 --- a/arch/x86/kernel/cpu/Makefile +++ b/arch/x86/kernel/cpu/Makefile @@ -34,7 +34,7 @@ obj-$(CONFIG_PROC_FS) += proc.o obj-$(CONFIG_IA32_FEAT_CTL) += feat_ctl.o ifdef CONFIG_CPU_SUP_INTEL -obj-y += intel.o intel_pconfig.o tsx.o +obj-y += intel.o tsx.o obj-$(CONFIG_PM) += intel_epb.o endif obj-$(CONFIG_CPU_SUP_AMD) += amd.o diff --git a/arch/x86/kernel/cpu/intel_pconfig.c b/arch/x86/kernel/cpu/intel_pconfig.c deleted file mode 100644 index 5be2b1790282..000000000000 --- a/arch/x86/kernel/cpu/intel_pconfig.c +++ /dev/null @@ -1,84 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Intel PCONFIG instruction support. - * - * Copyright (C) 2017 Intel Corporation - * - * Author: - * Kirill A. Shutemov - */ -#include -#include - -#include -#include - -#define PCONFIG_CPUID 0x1b - -#define PCONFIG_CPUID_SUBLEAF_MASK ((1 << 12) - 1) - -/* Subleaf type (EAX) for PCONFIG CPUID leaf (0x1B) */ -enum { - PCONFIG_CPUID_SUBLEAF_INVALID = 0, - PCONFIG_CPUID_SUBLEAF_TARGETID = 1, -}; - -/* Bitmask of supported targets */ -static u64 targets_supported __read_mostly; - -int pconfig_target_supported(enum pconfig_target target) -{ - /* - * We would need to re-think the implementation once we get > 64 - * PCONFIG targets. Spec allows up to 2^32 targets. - */ - BUILD_BUG_ON(PCONFIG_TARGET_NR >= 64); - - if (WARN_ON_ONCE(target >= 64)) - return 0; - return targets_supported & (1ULL << target); -} - -static int __init intel_pconfig_init(void) -{ - int subleaf; - - if (!boot_cpu_has(X86_FEATURE_PCONFIG)) - return 0; - - /* - * Scan subleafs of PCONFIG CPUID leaf. - * - * Subleafs of the same type need not to be consecutive. - * - * Stop on the first invalid subleaf type. All subleafs after the first - * invalid are invalid too. - */ - for (subleaf = 0; subleaf < INT_MAX; subleaf++) { - struct cpuid_regs regs; - - cpuid_count(PCONFIG_CPUID, subleaf, - ®s.eax, ®s.ebx, ®s.ecx, ®s.edx); - - switch (regs.eax & PCONFIG_CPUID_SUBLEAF_MASK) { - case PCONFIG_CPUID_SUBLEAF_INVALID: - /* Stop on the first invalid subleaf */ - goto out; - case PCONFIG_CPUID_SUBLEAF_TARGETID: - /* Mark supported PCONFIG targets */ - if (regs.ebx < 64) - targets_supported |= (1ULL << regs.ebx); - if (regs.ecx < 64) - targets_supported |= (1ULL << regs.ecx); - if (regs.edx < 64) - targets_supported |= (1ULL << regs.edx); - break; - default: - /* Unknown CPUID.PCONFIG subleaf: ignore */ - break; - } - } -out: - return 0; -} -arch_initcall(intel_pconfig_init); -- 2.37.3