Received: by 2002:a05:6a10:87d6:0:0:0:0 with SMTP id g22csp446263pxr; Sun, 10 Apr 2022 20:36:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrVcRzMbAs6lYHSBoo8gRZM7acKzn/jQJLII8hT3qwVCxAx5OR1GKHG3zis74gKkg2OAbS X-Received: by 2002:a05:6402:3712:b0:416:13bf:4fc5 with SMTP id ek18-20020a056402371200b0041613bf4fc5mr31355402edb.115.1649648181716; Sun, 10 Apr 2022 20:36:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649648181; cv=none; d=google.com; s=arc-20160816; b=Oi0pDcJfd2Sf9ICVcA3F0zO4IP7DP/X8a8T8Yqq1AxEAKxayisp1PwIZnCEFpL/4mb R75WcBBoNZi0qd0BKdCo4fIdR+2fyrn2nCjyT+AYQhVXaw7+NEvXpieCp4igJwZmtd5U WTYH01FjHH6FmHE0eSeADfBTXb1GERJ8MFKJrBrjtKM45NmgPLXH5P8LYSEElCLuY2nm noWEUzdrlW3NdP9w8411AF59NZFCIxTwNxliBtAdt/vbxCota9DSTbIpVfB2X4g9JyPP pSsL5KOhIsqdAPhrZts/Yjc9vqCqtpmLBBDyz86uT+Q1JrskqnubJ4n7lcetFRZlPJll QeeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=zrXl/Ox4i9B39TbM55bIllOYtcCvycRNpd790uo7UOo=; b=CKgnxzXCbGm0xhVtlOMqUTg/XqtBAdJ/zaaT61t9jRltssWde660DkYbhpi38yoevk PhG7NCnwXTBJK4ywAVATvzHsDBikyIPQe4GQq6X2ngL8L5nYvjLAdIesYR5Utszxvmw8 6rshahvvuKnQy7U2WTvRPjNPh7LL/8iL5JrxGicpvbKZ5Vbu4j2/Y4lbPW+UO8Z3hFuQ I+k/jhDn3bUfzLZqQoqp+aV9OjxZqCthnVIvxCgJI2KTqXhBasUjqI7HpvOKij74PQUU /MKXVHPUoEQ9hCjso8Mz2je6sfTVIOj1wC+VNLb7qULzBWN/Zp8c4tk5NBmx0snGd65K Xglw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=KJc+CaiI; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z8-20020a170906240800b006e88d626e23si1845140eja.897.2022.04.10.20.35.56; Sun, 10 Apr 2022 20:36:21 -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=@linutronix.de header.s=2020 header.b=KJc+CaiI; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240401AbiDIBat (ORCPT + 99 others); Fri, 8 Apr 2022 21:30:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240344AbiDIBaX (ORCPT ); Fri, 8 Apr 2022 21:30:23 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ACFF10EC43; Fri, 8 Apr 2022 18:27:34 -0700 (PDT) Date: Sat, 09 Apr 2022 01:27:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1649467653; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zrXl/Ox4i9B39TbM55bIllOYtcCvycRNpd790uo7UOo=; b=KJc+CaiIjr41KIGQuCorfXq+ylN20o347hYDTXsIrGiERCK38E0YZABqhKjQwvbRUOBBeh QCkQOA8xdlDOnGiOlj0ddhukHfkEufzVus5gX/vlfxC6uLZ1UYDCK3aVM+mi9fA0wP+XSh SUazpxyJPjddBytbHwqRNXQ8ed9PKJurj/DVTuJJo0GqkDrGJTORXej2BC2/qRcNEUZiv4 yWBY9/KP2wjfsxkdf0Ih3xUCYeW0XqGfkflmu5SPP6q/IZ2g842fJa6lJdE4/8b91j+7Gh zM1exPr5/0Np4cQxl13DmGibQ4ctZjYFkyEg3dURH0dKR4NOkJEABu+87QP6Og== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1649467653; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zrXl/Ox4i9B39TbM55bIllOYtcCvycRNpd790uo7UOo=; b=AtWCugji6zbN9PAuvVlth3qW9zpcyxgMP5I6xmk2dn25vqFN/MQoNyR+6hlcy6QIys2lMs TDhyIlgo1vil3iAg== From: "tip-bot2 for Kirill A. Shutemov" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/tdx] x86: Consolidate port I/O helpers Cc: "Kirill A. Shutemov" , Dave Hansen , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220405232939.73860-15-kirill.shutemov@linux.intel.com> References: <20220405232939.73860-15-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Message-ID: <164946765193.4207.8887148007606397599.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,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 The following commit has been merged into the x86/tdx branch of tip: Commit-ID: 1e8f93e18379d05da9fd130eb7d50988a20f8b9a Gitweb: https://git.kernel.org/tip/1e8f93e18379d05da9fd130eb7d50988a20f8b9a Author: Kirill A. Shutemov AuthorDate: Wed, 06 Apr 2022 02:29:23 +03:00 Committer: Dave Hansen CommitterDate: Thu, 07 Apr 2022 08:27:52 -07:00 x86: Consolidate port I/O helpers There are two implementations of port I/O helpers: one in the kernel and one in the boot stub. Move the helpers required for both to and use the one implementation everywhere. Signed-off-by: Kirill A. Shutemov Signed-off-by: Dave Hansen Reviewed-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20220405232939.73860-15-kirill.shutemov@linux.intel.com --- arch/x86/boot/boot.h | 35 +------------------------------- arch/x86/boot/compressed/misc.h | 2 +- arch/x86/include/asm/io.h | 22 +------------------ arch/x86/include/asm/shared/io.h | 34 ++++++++++++++++++++++++++++++- 4 files changed, 38 insertions(+), 55 deletions(-) create mode 100644 arch/x86/include/asm/shared/io.h diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h index 34c9dbb..22a474c 100644 --- a/arch/x86/boot/boot.h +++ b/arch/x86/boot/boot.h @@ -23,6 +23,7 @@ #include #include #include +#include #include "bitops.h" #include "ctype.h" #include "cpuflags.h" @@ -35,40 +36,6 @@ extern struct boot_params boot_params; #define cpu_relax() asm volatile("rep; nop") -/* Basic port I/O */ -static inline void outb(u8 v, u16 port) -{ - asm volatile("outb %0,%1" : : "a" (v), "dN" (port)); -} -static inline u8 inb(u16 port) -{ - u8 v; - asm volatile("inb %1,%0" : "=a" (v) : "dN" (port)); - return v; -} - -static inline void outw(u16 v, u16 port) -{ - asm volatile("outw %0,%1" : : "a" (v), "dN" (port)); -} -static inline u16 inw(u16 port) -{ - u16 v; - asm volatile("inw %1,%0" : "=a" (v) : "dN" (port)); - return v; -} - -static inline void outl(u32 v, u16 port) -{ - asm volatile("outl %0,%1" : : "a" (v), "dN" (port)); -} -static inline u32 inl(u16 port) -{ - u32 v; - asm volatile("inl %1,%0" : "=a" (v) : "dN" (port)); - return v; -} - static inline void io_delay(void) { const u16 DELAY_PORT = 0x80; diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h index 0d8e275..8a253e8 100644 --- a/arch/x86/boot/compressed/misc.h +++ b/arch/x86/boot/compressed/misc.h @@ -22,11 +22,11 @@ #include #include #include -#include #include #include #include #include +#include #include "tdx.h" diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index 638c1a2..a1eb218 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -44,6 +44,7 @@ #include #include #include +#include #define build_mmio_read(name, size, type, reg, barrier) \ static inline type name(const volatile void __iomem *addr) \ @@ -258,20 +259,6 @@ static inline void slow_down_io(void) #endif #define BUILDIO(bwl, bw, type) \ -static inline void out##bwl(type value, u16 port) \ -{ \ - asm volatile("out" #bwl " %" #bw "0, %w1" \ - : : "a"(value), "Nd"(port)); \ -} \ - \ -static inline type in##bwl(u16 port) \ -{ \ - type value; \ - asm volatile("in" #bwl " %w1, %" #bw "0" \ - : "=a"(value) : "Nd"(port)); \ - return value; \ -} \ - \ static inline void out##bwl##_p(type value, u16 port) \ { \ out##bwl(value, port); \ @@ -320,10 +307,8 @@ static inline void ins##bwl(u16 port, void *addr, unsigned long count) \ BUILDIO(b, b, u8) BUILDIO(w, w, u16) BUILDIO(l, , u32) +#undef BUILDIO -#define inb inb -#define inw inw -#define inl inl #define inb_p inb_p #define inw_p inw_p #define inl_p inl_p @@ -331,9 +316,6 @@ BUILDIO(l, , u32) #define insw insw #define insl insl -#define outb outb -#define outw outw -#define outl outl #define outb_p outb_p #define outw_p outw_p #define outl_p outl_p diff --git a/arch/x86/include/asm/shared/io.h b/arch/x86/include/asm/shared/io.h new file mode 100644 index 0000000..c0ef921 --- /dev/null +++ b/arch/x86/include/asm/shared/io.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_SHARED_IO_H +#define _ASM_X86_SHARED_IO_H + +#include + +#define BUILDIO(bwl, bw, type) \ +static inline void __out##bwl(type value, u16 port) \ +{ \ + asm volatile("out" #bwl " %" #bw "0, %w1" \ + : : "a"(value), "Nd"(port)); \ +} \ + \ +static inline type __in##bwl(u16 port) \ +{ \ + type value; \ + asm volatile("in" #bwl " %w1, %" #bw "0" \ + : "=a"(value) : "Nd"(port)); \ + return value; \ +} + +BUILDIO(b, b, u8) +BUILDIO(w, w, u16) +BUILDIO(l, , u32) +#undef BUILDIO + +#define inb __inb +#define inw __inw +#define inl __inl +#define outb __outb +#define outw __outw +#define outl __outl + +#endif