Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F398B248F60 for ; Fri, 20 Jun 2025 23:21:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750461681; cv=none; b=Ai1Vzm+Q05GrVoMTrmIRS4dwxiQpFfZcMifIXd0l8B7D07plz1ZXD1jnlCB0rGOpF5iW7pBZZsANdsLNAAUgQ+GBUSDyADMplqr/aMZkoiGddtlGlHY5qJYpIlzHXcU5HQ88Mw87YK0PA0dEVHjzdTOKIrztsN7vCm8lL7AyiUY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750461681; c=relaxed/simple; bh=rjAOOg5rAqiE8TcyI+gxmP/J4K5fE0ChxFTfHJ5WsPg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bz/K0hNx/5j6PvrM0oFwseSXQmwPkg/FrUs5zQQpMMX4KmZNT4IGwbEXH78nzIpZDrYzKwayFIPp9OCrOkjFfnZcQxSfAPMn78ykunyPu/iuk0qbnFZv3in4SZjDTy5f02Em8t18CgmY1tOYG+cHS4QClCb6VqYIxAt0bekYgEg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=tlSDHG08; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tlSDHG08" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-748a4f5e735so1829503b3a.3 for ; Fri, 20 Jun 2025 16:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1750461679; x=1751066479; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=94GJWP70zctYgbzarRKMjhu8IQXsXSiZ1mX5cwoCPok=; b=tlSDHG08ICUgIZF586gLlTpnHZiAkHfoEmmgRp9iLSQEu4GYvRJNryk7hUtQVzlVrK m9zOOEoJHEPYbIqxg/1MHPf7IqcCTzIIFRCjNaKTD43NbSZIW/69RmA1OrDaCm6pnmI3 /wmO6T2oyOayP1eOSchrvyRwjYYZeBp8DRMTtkcKrN9Mvj6M3vW8cVGnFWu2rTBOqvtg DtCoOw30YNCvhdFlh8A6OgvHgZvxSDu+Jv3lODqnKTg4Je5qKAEU5RheqK22SigvwV9S QN3+3IJAKn1k7aeyvcr6CtxoNWsqvWq0k3ZOCyQGumwKAT0J3iJG1H5QFGWp8pfihhqp S+Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750461679; x=1751066479; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=94GJWP70zctYgbzarRKMjhu8IQXsXSiZ1mX5cwoCPok=; b=nbgCd6CI+nNSiC4+atyX/YocRpCq6Gm2DfK2Ce0YAmS6T0xe9mpMlKqRZ9iWsLxjBW 4nPZLF5BAIhpkqc3dgFWgJagAAYOry2pRn7BnurE6uGnh8CV2Xg3VOAueyy+/SCvp+K8 DKCWxtWOYRlGJDZjrxMeEXMlnUa9xxiCd9Yxl/+TXmB4Rbwf4ZINMNlKzTXaRt93tA+B hPGlikfP4syeejY9LJcK58GlTZ6DfkhTgoU7aQmTNSiRlr6VBGpMIY9dK8UQu9QGsXu/ dIWIyqtixpdcJ64raZWASOJlfWmtQiWDjJdpi8OPrTXjgHCsWsXrNg5ogihmM/rB6LyB R73w== X-Forwarded-Encrypted: i=1; AJvYcCWMl1gxpr1exGG8fN3a0fhJSf99pP9IQD4hlkV/XRQ2r5omxUDloeGH14rMMh6YgKxMyHm5KBTQK6Y=@vger.kernel.org X-Gm-Message-State: AOJu0YyvMtv+VWrsAAmOPWIUFr5+P/hLg3ypEKFlntJ5NusQB3yFI0Nj CR8aTjG+livh+vUWWUEvkRil563ylhJwoUgx3NmlmxaDh8wUq6cPNYplm/VXOJWKlmux0y6vJ5B Hd5jhn3p5XvxGng== X-Google-Smtp-Source: AGHT+IE4VMXsve8M9dbvTR8GNNExOeCyx2MQbPfsc8q8B1evW0kfg7x5+2IlqSW/SM0OnBHCr9pUi8Np41/tTQ== X-Received: from pfrh7.prod.google.com ([2002:aa7:9f47:0:b0:748:4f7c:c605]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:3a0a:b0:73d:fa54:afb9 with SMTP id d2e1a72fcca58-7490d786d97mr6243442b3a.7.1750461679257; Fri, 20 Jun 2025 16:21:19 -0700 (PDT) Date: Fri, 20 Jun 2025 23:20:09 +0000 In-Reply-To: <20250620232031.2705638-1-dmatlack@google.com> Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250620232031.2705638-1-dmatlack@google.com> X-Mailer: git-send-email 2.50.0.rc2.701.gf1e915cc24-goog Message-ID: <20250620232031.2705638-12-dmatlack@google.com> Subject: [PATCH 11/33] tools headers: Import x86 MMIO helper overrides From: David Matlack To: Alex Williamson Cc: Aaron Lewis , Adhemerval Zanella , Adithya Jayachandran , Andrew Jones , Ard Biesheuvel , Arnaldo Carvalho de Melo , Bibo Mao , Claudio Imbrenda , Dan Williams , Dave Jiang , David Matlack , dmaengine@vger.kernel.org, Huacai Chen , James Houghton , Jason Gunthorpe , Joel Granados , Josh Hilke , Kevin Tian , kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, "Mike Rapoport (Microsoft)" , Paolo Bonzini , Pasha Tatashin , "Pratik R. Sampat" , Saeed Mahameed , Sean Christopherson , Shuah Khan , Vinicius Costa Gomes , Vipin Sharma , Wei Yang , "Yury Norov [NVIDIA]" Content-Type: text/plain; charset="UTF-8" Import the x86-specific overrides for from the kernel headers into tools/include/. Changes made when importing: - Replace CONFIG_X86_64 with __x86_64__. Signed-off-by: David Matlack --- tools/arch/x86/include/asm/io.h | 75 +++++++++++++++++++++++++++++++++ tools/include/asm/io.h | 4 ++ 2 files changed, 79 insertions(+) create mode 100644 tools/arch/x86/include/asm/io.h diff --git a/tools/arch/x86/include/asm/io.h b/tools/arch/x86/include/asm/io.h new file mode 100644 index 000000000000..4c787a2363de --- /dev/null +++ b/tools/arch/x86/include/asm/io.h @@ -0,0 +1,75 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _TOOLS_ASM_X86_IO_H +#define _TOOLS_ASM_X86_IO_H + +#include +#include + +#define build_mmio_read(name, size, type, reg, barrier) \ +static inline type name(const volatile void __iomem *addr) \ +{ type ret; asm volatile("mov" size " %1,%0":reg (ret) \ +:"m" (*(volatile type __force *)addr) barrier); return ret; } + +#define build_mmio_write(name, size, type, reg, barrier) \ +static inline void name(type val, volatile void __iomem *addr) \ +{ asm volatile("mov" size " %0,%1": :reg (val), \ +"m" (*(volatile type __force *)addr) barrier); } + +build_mmio_read(readb, "b", unsigned char, "=q", :"memory") +build_mmio_read(readw, "w", unsigned short, "=r", :"memory") +build_mmio_read(readl, "l", unsigned int, "=r", :"memory") + +build_mmio_read(__readb, "b", unsigned char, "=q", ) +build_mmio_read(__readw, "w", unsigned short, "=r", ) +build_mmio_read(__readl, "l", unsigned int, "=r", ) + +build_mmio_write(writeb, "b", unsigned char, "q", :"memory") +build_mmio_write(writew, "w", unsigned short, "r", :"memory") +build_mmio_write(writel, "l", unsigned int, "r", :"memory") + +build_mmio_write(__writeb, "b", unsigned char, "q", ) +build_mmio_write(__writew, "w", unsigned short, "r", ) +build_mmio_write(__writel, "l", unsigned int, "r", ) + +#define readb readb +#define readw readw +#define readl readl +#define readb_relaxed(a) __readb(a) +#define readw_relaxed(a) __readw(a) +#define readl_relaxed(a) __readl(a) +#define __raw_readb __readb +#define __raw_readw __readw +#define __raw_readl __readl + +#define writeb writeb +#define writew writew +#define writel writel +#define writeb_relaxed(v, a) __writeb(v, a) +#define writew_relaxed(v, a) __writew(v, a) +#define writel_relaxed(v, a) __writel(v, a) +#define __raw_writeb __writeb +#define __raw_writew __writew +#define __raw_writel __writel + +#ifdef __x86_64__ + +build_mmio_read(readq, "q", u64, "=r", :"memory") +build_mmio_read(__readq, "q", u64, "=r", ) +build_mmio_write(writeq, "q", u64, "r", :"memory") +build_mmio_write(__writeq, "q", u64, "r", ) + +#define readq_relaxed(a) __readq(a) +#define writeq_relaxed(v, a) __writeq(v, a) + +#define __raw_readq __readq +#define __raw_writeq __writeq + +/* Let people know that we have them */ +#define readq readq +#define writeq writeq + +#endif /* __x86_64__ */ + +#include + +#endif /* _TOOLS_ASM_X86_IO_H */ diff --git a/tools/include/asm/io.h b/tools/include/asm/io.h index 9ae219b12604..eed5066f25c4 100644 --- a/tools/include/asm/io.h +++ b/tools/include/asm/io.h @@ -2,6 +2,10 @@ #ifndef _TOOLS_ASM_IO_H #define _TOOLS_ASM_IO_H +#if defined(__i386__) || defined(__x86_64__) +#include "../../arch/x86/include/asm/io.h" +#else #include +#endif #endif /* _TOOLS_ASM_IO_H */ -- 2.50.0.rc2.701.gf1e915cc24-goog