From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 369D4C49EA6 for ; Sat, 26 Jun 2021 14:17:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 158A161455 for ; Sat, 26 Jun 2021 14:17:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230090AbhFZOT4 (ORCPT ); Sat, 26 Jun 2021 10:19:56 -0400 Received: from mga09.intel.com ([134.134.136.24]:42501 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbhFZOTu (ORCPT ); Sat, 26 Jun 2021 10:19:50 -0400 IronPort-SDR: 6FvbjGHQ43u0ReBwYbsL36hgrUXlGs0qdd58AhhjXjO7/J9CI2aZsXE7gyQK5OeyIvBaH2UQ57 XnDDAQGwUDKg== X-IronPort-AV: E=McAfee;i="6200,9189,10027"; a="207729769" X-IronPort-AV: E=Sophos;i="5.83,301,1616482800"; d="scan'208";a="207729769" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2021 07:17:28 -0700 X-IronPort-AV: E=Sophos;i="5.83,301,1616482800"; d="scan'208";a="624775841" Received: from mlubyani-mobl2.amr.corp.intel.com (HELO skuppusw-desk1.amr.corp.intel.com) ([10.254.8.25]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2021 07:17:27 -0700 From: Kuppuswamy Sathyanarayanan To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Andy Lutomirski Cc: Peter H Anvin , Dave Hansen , Tony Luck , Dan Williams , Andi Kleen , Kirill Shutemov , Sean Christopherson , Kuppuswamy Sathyanarayanan , x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 01/10] x86/io: Allow to override inX() and outX() implementation Date: Sat, 26 Jun 2021 07:17:09 -0700 Message-Id: <2da735c633b5b860f5f8a1626f8dd2b920ec7215.1624716673.git.sathyanarayanan.kuppuswamy@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Kirill A. Shutemov" The patch allows to override the implementation of the port IO helpers. TDX code will provide an implementation that redirect the helpers to paravirt calls. Signed-off-by: Kirill A. Shutemov Reviewed-by: Andi Kleen Reviewed-by: Tony Luck Signed-off-by: Kuppuswamy Sathyanarayanan --- arch/x86/include/asm/io.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index 841a5d104afa..be96bf1e667a 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -271,18 +271,26 @@ static inline bool sev_key_active(void) { return false; } #endif /* CONFIG_AMD_MEM_ENCRYPT */ +#ifndef __out +#define __out(bwl, bw) \ + asm volatile("out" #bwl " %" #bw "0, %w1" : : "a"(value), "Nd"(port)) +#endif + +#ifndef __in +#define __in(bwl, bw) \ + asm volatile("in" #bwl " %w1, %" #bw "0" : "=a"(value) : "Nd"(port)) +#endif + #define BUILDIO(bwl, bw, type) \ static inline void out##bwl(unsigned type value, int port) \ { \ - asm volatile("out" #bwl " %" #bw "0, %w1" \ - : : "a"(value), "Nd"(port)); \ + __out(bwl, bw); \ } \ \ static inline unsigned type in##bwl(int port) \ { \ unsigned type value; \ - asm volatile("in" #bwl " %w1, %" #bw "0" \ - : "=a"(value) : "Nd"(port)); \ + __in(bwl, bw); \ return value; \ } \ \ -- 2.25.1