From patchwork Tue Dec 5 10:49:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 173974 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3358697vqy; Tue, 5 Dec 2023 03:21:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgRwJ7fUa1u6a+Jfu/c7UvofvzKzvCSz608ao55n/q9NhB8pcIdYDuEjkjVFj3m7yf1oA1 X-Received: by 2002:a17:903:186:b0:1d0:afd5:1e77 with SMTP id z6-20020a170903018600b001d0afd51e77mr2164401plg.42.1701775307982; Tue, 05 Dec 2023 03:21:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701775307; cv=none; d=google.com; s=arc-20160816; b=rcsAuP/ft+8ET1WxaU47o8xmxvqnfp2UmLoHpvJO3JvpLub9MRkp13+SQHEgwUDzwV FZlsnzUDC9u/mQjTxbTuL5yIKdfQ6VXCpyDrpkxb71z4w7BltQe4uRKl8/TvZsAC+Dvc fgW2Ccxdqda2PNIRDeE+MXgZW6Is9DywKU7Bkpm/yE7jiC52uM1O7V6YB/ri57cbCSRQ 6h2grbEQLYjQCmtkxOSGHs37OnS7oqUt9ramRVg9fE3xEUNPkrWVK7PU7bsGJs1DF9hj bODY/qFpFykbuQyZBJuuvVg72yJoTiVeN5GvxNu14UldpOmmT9TLdO94901NXtbC6gOf P8Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+Bh3zJ9GjTHXhAgGdNwXfMt22iqjFGzJ4vn3sFziR1c=; fh=uCCWEUVpLc/xDP/D3WvGY/BxHU9d0NQYu/T71GEsNmA=; b=tu/+Z12bVtg5S+WOgKUZBUQ+90LFtQiyJbeoyw30FdTbTjnoMPJE3we4sTJ+XeqX6u 8xPhQAEcD9m6Bzm6qJcX03RPf++Xq3yAc5UHXB+c8vLOfHe6cJgmrb6Pfumb4IYHBTua 4pa18euVFC6p6eGnG2y6QXvtribueQEEQrebevT/fu4aP7xvh/bsjllOCOlQVOlK7sd1 FE91vEIxtB47Wzs2QvXH2IUfKUJztWGoQAErMDyFcfsK1JiFWT94HKNbayVKfADqJSxw iY0wM2bWsLxlONvkPRgLrNO8758VESN2FM3lHF+eS5c0+ArX7HTHvgYKV0aH9ZJJuPY/ u+Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UcqxstiH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id y6-20020a170902b48600b001d0afa2f5e0si2835110plr.530.2023.12.05.03.21.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 03:21:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UcqxstiH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id E471880A49B8; Tue, 5 Dec 2023 03:21:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442094AbjLELVW (ORCPT + 99 others); Tue, 5 Dec 2023 06:21:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376894AbjLELVO (ORCPT ); Tue, 5 Dec 2023 06:21:14 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEAD1116; Tue, 5 Dec 2023 03:21:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701775281; x=1733311281; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jUmKwc/SMnY0ZGiDGUCu3QSu4hVAIRhy7FwTA3XKz/Q=; b=UcqxstiHIZSc8jrp2o+ard1Tb7JXKFap7RBvlFaeITZSSHX+MMGT50JX fVCnKpX3kQY8Lr1umK4x08Nk62M9Xk070xYidcjbJhLf8VGmoRuMsuuKF QaJZDVKuVAjaKI13HejX3zimdXcUOO6ZwxOtXfoPBATi/YdgQxOVMygIM 3U7+KvC9P4VJNMYmULCjppdF5AB3J71xaOY6Zh3wkQKV/E6dDd7f8Yail lj328C5G2TFKTiz/hPx0vUMOfexbM4yfcxof/IPlHrsgiM32ue7q/qE0t BN5qKNCED9w7HxGuZlRUiIXVeOBN6P5kvQnQYNzr5lGtPfnjWFCx3TcPN Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="942369" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="942369" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2023 03:21:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="1018192905" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="1018192905" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga006.fm.intel.com with ESMTP; 05 Dec 2023 03:21:16 -0800 From: Xin Li To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, linux-hyperv@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, luto@kernel.org, pbonzini@redhat.com, seanjc@google.com, peterz@infradead.org, jgross@suse.com, ravi.v.shankar@intel.com, mhiramat@kernel.org, andrew.cooper3@citrix.com, jiangshanlai@gmail.com, nik.borisov@suse.com, shan.kang@intel.com Subject: [PATCH v13 03/35] x86/trapnr: Add event type macros to Date: Tue, 5 Dec 2023 02:49:52 -0800 Message-ID: <20231205105030.8698-4-xin3.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231205105030.8698-1-xin3.li@intel.com> References: <20231205105030.8698-1-xin3.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 05 Dec 2023 03:21:39 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784440745135793676 X-GMAIL-MSGID: 1784440745135793676 Intel VT-x classifies events into eight different types, which is inherited by FRED for event identification. As such, event type becomes a common x86 concept, and should be defined in a common x86 header. Add event type macros to , and use it in . Suggested-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v10: * A few comment fixes and improvements (Andrew Cooper). --- arch/x86/include/asm/trapnr.h | 12 ++++++++++++ arch/x86/include/asm/vmx.h | 17 +++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/trapnr.h b/arch/x86/include/asm/trapnr.h index f5d2325aa0b7..8d1154cdf787 100644 --- a/arch/x86/include/asm/trapnr.h +++ b/arch/x86/include/asm/trapnr.h @@ -2,6 +2,18 @@ #ifndef _ASM_X86_TRAPNR_H #define _ASM_X86_TRAPNR_H +/* + * Event type codes used by FRED, Intel VT-x and AMD SVM + */ +#define EVENT_TYPE_EXTINT 0 // External interrupt +#define EVENT_TYPE_RESERVED 1 +#define EVENT_TYPE_NMI 2 // NMI +#define EVENT_TYPE_HWEXC 3 // Hardware originated traps, exceptions +#define EVENT_TYPE_SWINT 4 // INT n +#define EVENT_TYPE_PRIV_SWEXC 5 // INT1 +#define EVENT_TYPE_SWEXC 6 // INTO, INT3 +#define EVENT_TYPE_OTHER 7 // FRED SYSCALL/SYSENTER, VT-x MTF + /* Interrupts/Exceptions */ #define X86_TRAP_DE 0 /* Divide-by-zero */ diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h index 0e73616b82f3..4dba17363008 100644 --- a/arch/x86/include/asm/vmx.h +++ b/arch/x86/include/asm/vmx.h @@ -17,6 +17,7 @@ #include #include +#include #include #define VMCS_CONTROL_BIT(x) BIT(VMX_FEATURE_##x & 0x1f) @@ -374,14 +375,14 @@ enum vmcs_field { #define VECTORING_INFO_DELIVER_CODE_MASK INTR_INFO_DELIVER_CODE_MASK #define VECTORING_INFO_VALID_MASK INTR_INFO_VALID_MASK -#define INTR_TYPE_EXT_INTR (0 << 8) /* external interrupt */ -#define INTR_TYPE_RESERVED (1 << 8) /* reserved */ -#define INTR_TYPE_NMI_INTR (2 << 8) /* NMI */ -#define INTR_TYPE_HARD_EXCEPTION (3 << 8) /* processor exception */ -#define INTR_TYPE_SOFT_INTR (4 << 8) /* software interrupt */ -#define INTR_TYPE_PRIV_SW_EXCEPTION (5 << 8) /* ICE breakpoint - undocumented */ -#define INTR_TYPE_SOFT_EXCEPTION (6 << 8) /* software exception */ -#define INTR_TYPE_OTHER_EVENT (7 << 8) /* other event */ +#define INTR_TYPE_EXT_INTR (EVENT_TYPE_EXTINT << 8) /* external interrupt */ +#define INTR_TYPE_RESERVED (EVENT_TYPE_RESERVED << 8) /* reserved */ +#define INTR_TYPE_NMI_INTR (EVENT_TYPE_NMI << 8) /* NMI */ +#define INTR_TYPE_HARD_EXCEPTION (EVENT_TYPE_HWEXC << 8) /* processor exception */ +#define INTR_TYPE_SOFT_INTR (EVENT_TYPE_SWINT << 8) /* software interrupt */ +#define INTR_TYPE_PRIV_SW_EXCEPTION (EVENT_TYPE_PRIV_SWEXC << 8) /* ICE breakpoint */ +#define INTR_TYPE_SOFT_EXCEPTION (EVENT_TYPE_SWEXC << 8) /* software exception */ +#define INTR_TYPE_OTHER_EVENT (EVENT_TYPE_OTHER << 8) /* other event */ /* GUEST_INTERRUPTIBILITY_INFO flags. */ #define GUEST_INTR_STATE_STI 0x00000001