From patchwork Thu Jul 6 05:14:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 116515 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2340712vqx; Wed, 5 Jul 2023 23:02:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlF3rNdO8coOkLAMPvWWFIqX+7CE4KaiQJPmPKocsxKoX94X5A3B0B94CMWis5rJ62VnvYai X-Received: by 2002:a17:903:2351:b0:1b8:86a1:9cf with SMTP id c17-20020a170903235100b001b886a109cfmr784389plh.32.1688623375902; Wed, 05 Jul 2023 23:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688623375; cv=none; d=google.com; s=arc-20160816; b=Hm8UFClAe6hrO+jpzuUeyifBCNx9Nwyjxk4r5dzr3ILLPqWiMXI5l6C+/yj99ojtDz kF729af9LpIqL1twAeQx2nECa4SUoY5g/xEmMseZ3DIdTn+dayhbcCuAwZJxXXBE18/6 MjpRNsXjTOkximzv4qU86hh9vNiFTSXUNKpmH8Ozlc0W5PQrs9TqqNfaWG1i/z1dmVzW 6EYXJxqM2KItqXuClOuc0IFXWOWHaTcd9ctOPTWeDrPH7FFrIpwpq2b4nU7atVvYdV9e GqBkf7RLyK0sPf+5IHBlDV9gbihLcJV5ak1EpD8ht8PWTL2KFGkj6aYvjRZb0ODgzjuQ M7Ww== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=9lskaFPnE/pM2bfgN3zuEW4en/HSiZ+jw6v1j2Sv2H4=; fh=LsnfAt2Iq3WeV2i1FYvXkHZFENBn7bw+l46deyspwU4=; b=g3kYDG/EGVLx76mVFkDz94yHJYvDxC6NwcVsvS1sXeAu7+MrD7VQaRKJa0wdgxRLuw hZ+18+Soy0ETp002B/UxkKozSDyj7MOTHoUPrHBs1Idbt68LQh+NyziZcKYaitc4agbJ kGCvL+XoFc020ZJOoNMgwX9PVseJdgVuqASk0gWMCQoEqKFkSY7cY8ABkhLUxlvVNQo/ SZDFDFJeIr1JKf1wtmixMZIoHP/76U5tlAzGQERE/O3jhznmaaF/NkQLlg7IMd2lCjHi MbI4Q2gZ2JpNGhCiPsXRjOdljihqpLwVOhtOntFB8LA1KpL+4y5Iath2jMYZK7mrNnAz i3IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="N/vc52Kb"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q11-20020a170902eb8b00b001b89bc24ddcsi666517plg.355.2023.07.05.23.02.43; Wed, 05 Jul 2023 23:02:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="N/vc52Kb"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232869AbjGFFmh (ORCPT + 99 others); Thu, 6 Jul 2023 01:42:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231950AbjGFFmf (ORCPT ); Thu, 6 Jul 2023 01:42:35 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F14B819B7; Wed, 5 Jul 2023 22:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688622153; x=1720158153; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=fhO+nRl8dQCGf5/sU9bXTh4CEf27dyW1SWH8GIwBd0g=; b=N/vc52KbRQQypIL00pIZJd7DKMY4oQuFkcavTMknxWJwikmrffLiXhg2 EfJov0fKfcxlFrkJuD8XEQJt7Fe/oWxsvUeLYqLSShhUA/oWFoMwJiJOG dVBIIw7vybvc+eURgtyW+nFEhmyZ9DH07egqsllc0wV+X2xO9LlSDf2Jx 1yk8wZa5Pw3yYA0RZgeoiW50fZFpfq9TzwqGtF9OakGdKq5SAXrO3KBsw dAe9plm85NSN75QLqPI9iFAiMdZUSjbWuUuhuq5K3fexq9Ng4JnW1LU+f wYrMBEwAUZrrXLS3i8f04VHLCTB2lwe7tdHlPjBqZSHdT1dC3n2j7rfDk A==; X-IronPort-AV: E=McAfee;i="6600,9927,10762"; a="362381887" X-IronPort-AV: E=Sophos;i="6.01,184,1684825200"; d="scan'208";a="362381887" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jul 2023 22:42:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10762"; a="696728942" X-IronPort-AV: E=Sophos;i="6.01,184,1684825200"; d="scan'208";a="696728942" Received: from unknown (HELO fred..) ([172.25.112.68]) by orsmga006.jf.intel.com with ESMTP; 05 Jul 2023 22:42:24 -0700 From: Xin Li To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, x86@kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, seanjc@google.com, pbonzini@redhat.com, xin3.li@intel.com Subject: [PATCH] x86/trapnr: Add event type macros to Date: Wed, 5 Jul 2023 22:14:43 -0700 Message-Id: <20230706051443.2054-1-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770649945330127518?= X-GMAIL-MSGID: =?utf-8?q?1770649945330127518?= 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) Signed-off-by: Xin Li --- arch/x86/include/asm/trapnr.h | 18 ++++++++++++++++++ arch/x86/include/asm/vmx.h | 17 +++++++++-------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/trapnr.h b/arch/x86/include/asm/trapnr.h index f5d2325aa0b7..356af7ceab4d 100644 --- a/arch/x86/include/asm/trapnr.h +++ b/arch/x86/include/asm/trapnr.h @@ -2,6 +2,24 @@ #ifndef _ASM_X86_TRAPNR_H #define _ASM_X86_TRAPNR_H +/* + * Event type codes used by both Intel VT-x and FRED + */ +/* Maskable external interrupt */ +#define EVENT_TYPE_HWINT 0 +#define EVENT_TYPE_RESERVED 1 +#define EVENT_TYPE_NMI 2 +/* Hardware exceptions (e.g., page fault) */ +#define EVENT_TYPE_HWFAULT 3 +/* Software interrupt (INT n) */ +#define EVENT_TYPE_SWINT 4 +/* INT1 (ICEBP) */ +#define EVENT_TYPE_PRIVSW 5 +/* Software exception (INT3 or INTO) */ +#define EVENT_TYPE_SWFAULT 6 +/* VT-x MTF or FRED SYSCALL/SYSENTER */ +#define EVENT_TYPE_OTHER 7 + /* 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 0d02c4aafa6f..15a096fceb1d 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_HWINT << 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_HWFAULT << 8) /* processor exception */ +#define INTR_TYPE_SOFT_INTR (EVENT_TYPE_SWINT << 8) /* software interrupt */ +#define INTR_TYPE_PRIV_SW_EXCEPTION (EVENT_TYPE_PRIVSW << 8) /* ICE breakpoint - undocumented */ +#define INTR_TYPE_SOFT_EXCEPTION (EVENT_TYPE_SWFAULT << 8) /* software exception */ +#define INTR_TYPE_OTHER_EVENT (EVENT_TYPE_OTHER << 8) /* other event */ /* GUEST_INTERRUPTIBILITY_INFO flags. */ #define GUEST_INTR_STATE_STI 0x00000001