From patchwork Thu Mar 14 23:26:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13592915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1FC7AC54E5D for ; Thu, 14 Mar 2024 23:28:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sE7VFHn5REc6u3Z/8CH/rmrIZWpBwwSy1AaKyLd+6jo=; b=WRRYPHsxnGAq3e tgKjmhDAbQgvaljGnAIHd41xpm9wHhFdvApsT6yhUDP0dg5LTuzy9GzcYX4jMX/5fhLYDlGXLyCEB nIqzHqHhAzsy16Tn9zabfL2BtKTU5G5JGCXO99+dhri0n7+EUjQ9MB9ZJrVIFFehlrmO1xLh/XpE7 +xPjl1m3uaVWqW4H/7GSgGaiJexsIMeWAB8ahN62UnLW3sW1TNG/GvE54oeLMFR941QYu+Btu4cfT qrLR1fWCL1MjvgbNtr/ir8J0fWpGyOivXBmkbbB62XtD0AJTjWAw9rWeeSdkvLUQN7TU1cz/RsjYi FVHLeKZjI+i0zc2pzvyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkuUW-0000000G0kb-3aEQ; Thu, 14 Mar 2024 23:28:04 +0000 Received: from mail-pl1-x649.google.com ([2607:f8b0:4864:20::649]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkuTH-0000000Fzsp-26Q6 for linux-arm-kernel@lists.infradead.org; Thu, 14 Mar 2024 23:26:53 +0000 Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1ddc9430263so16859435ad.1 for ; Thu, 14 Mar 2024 16:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710458804; x=1711063604; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=xxEEnp8KYxWW22Dja8/hqreyUmSSC0e9nt+hWHrby04=; b=JKW+Q0ubYJDRql1fynfXhZQTZClAOy4INC8uTrPpIp+z9qkkd2IHQfZ9kZwChWNNZv WnzGJkPMyqqctuTDwqg1iseYqb4o3gYjg0AVMPYJIM4ObWdU5t/uGSsF8XE+vrSkS9Dw 1XRNMr+Isvze+WEtY5p9COTXzCdGX91AaMtmoOD5TAFftIBiqEl5+1aa77Gbex6Xvo8i 2RPRpbkZHJuMAsUR2HE0zcfLyg0ADItubr4t5DLtCRUTjZLcOEKJWtQWgtm9nCOKx6AV PCCIewMpPhz3+ocz1qrDI/aNWhv1kHogLie6adH35aYssp8Sjn+EXsY21eYkBlya/O43 H0MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710458804; x=1711063604; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xxEEnp8KYxWW22Dja8/hqreyUmSSC0e9nt+hWHrby04=; b=oz4XrTShwayb0JIq9bjDfcIc8yzeox+rVqijCPi2fvp305kF/2wUS/At5fiZ6I38Nq /ay2Znro4PvXLSCkX/V07nKGC4r1glT4dpnZU+8okmOatZsTkVjxxNcy6TCJT6IkDiJs dYRdD8O9K6ot3AIpazVioPxhE4UQbg5kYrk+e67nGLJ40ubumfCrnvQD31TzfuiN8zyo zR/8z9qU/tyIr41aCu2oQnfcteZJu9jd6NYyAr+bK8sQPChq9TcpzCrduG4c5EVXjTLM IAYO0XzCwvKK0y36a08moqSkdCbCHhu6fIOlYrxVFN0hzCg0ZoAAZ3XAqlQf58h9Z1P5 1ERg== X-Gm-Message-State: AOJu0YxZfRoSCPPD5s7RNlzS6z86SXcVPX0jKOw70+YXaXHB8yBC9OE2 Y7oxiNmOQhkC8lWE8DbsPrzgb8JtexZMmBoaxSJEd2oG8euFXyr25QkoZug0LQxysy7Dr9egY3i +Zg== X-Google-Smtp-Source: AGHT+IH3tWVDzScYAxWAoO+AJJrzIFuBnfUykicaYWmU+HGG/cysXNug5oRiY871AjgR+7oBptYedZH/VEU= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:903:41c2:b0:1dd:7d71:5900 with SMTP id u2-20020a17090341c200b001dd7d715900mr9743ple.1.1710458803732; Thu, 14 Mar 2024 16:26:43 -0700 (PDT) Date: Thu, 14 Mar 2024 16:26:21 -0700 In-Reply-To: <20240314232637.2538648-1-seanjc@google.com> Mime-Version: 1.0 References: <20240314232637.2538648-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.291.gc1ea87d7ee-goog Message-ID: <20240314232637.2538648-3-seanjc@google.com> Subject: [PATCH 02/18] KVM: sefltests: Add kvm_util_types.h to hold common types, e.g. vm_vaddr_t From: Sean Christopherson To: Marc Zyngier , Oliver Upton , Paolo Bonzini , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Sean Christopherson , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Ackerley Tng X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240314_162647_754180_189765BE X-CRM114-Status: GOOD ( 16.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move the base types unique to KVM selftests out of kvm_util.h and into a new header, kvm_util_types.h. This will allow kvm_util_arch.h, i.e. core arch headers, to reference common types, e.g. vm_vaddr_t and vm_paddr_t. No functional change intended. Signed-off-by: Sean Christopherson Reviewed-by: Ackerley Tng --- .../testing/selftests/kvm/include/kvm_util.h | 16 +-------------- .../selftests/kvm/include/kvm_util_types.h | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 tools/testing/selftests/kvm/include/kvm_util_types.h diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h index 95baee5142a7..acdcddf78e3f 100644 --- a/tools/testing/selftests/kvm/include/kvm_util.h +++ b/tools/testing/selftests/kvm/include/kvm_util.h @@ -21,28 +21,14 @@ #include #include "kvm_util_arch.h" +#include "kvm_util_types.h" #include "sparsebit.h" -/* - * Provide a version of static_assert() that is guaranteed to have an optional - * message param. If _ISOC11_SOURCE is defined, glibc (/usr/include/assert.h) - * #undefs and #defines static_assert() as a direct alias to _Static_assert(), - * i.e. effectively makes the message mandatory. Many KVM selftests #define - * _GNU_SOURCE for various reasons, and _GNU_SOURCE implies _ISOC11_SOURCE. As - * a result, static_assert() behavior is non-deterministic and may or may not - * require a message depending on #include order. - */ -#define __kvm_static_assert(expr, msg, ...) _Static_assert(expr, msg) -#define kvm_static_assert(expr, ...) __kvm_static_assert(expr, ##__VA_ARGS__, #expr) - #define KVM_DEV_PATH "/dev/kvm" #define KVM_MAX_VCPUS 512 #define NSEC_PER_SEC 1000000000L -typedef uint64_t vm_paddr_t; /* Virtual Machine (Guest) physical address */ -typedef uint64_t vm_vaddr_t; /* Virtual Machine (Guest) virtual address */ - struct userspace_mem_region { struct kvm_userspace_memory_region2 region; struct sparsebit *unused_phy_pages; diff --git a/tools/testing/selftests/kvm/include/kvm_util_types.h b/tools/testing/selftests/kvm/include/kvm_util_types.h new file mode 100644 index 000000000000..764491366eb9 --- /dev/null +++ b/tools/testing/selftests/kvm/include/kvm_util_types.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef SELFTEST_KVM_UTIL_TYPES_H +#define SELFTEST_KVM_UTIL_TYPES_H + +/* + * Provide a version of static_assert() that is guaranteed to have an optional + * message param. If _ISOC11_SOURCE is defined, glibc (/usr/include/assert.h) + * #undefs and #defines static_assert() as a direct alias to _Static_assert(), + * i.e. effectively makes the message mandatory. Many KVM selftests #define + * _GNU_SOURCE for various reasons, and _GNU_SOURCE implies _ISOC11_SOURCE. As + * a result, static_assert() behavior is non-deterministic and may or may not + * require a message depending on #include order. + */ +#define __kvm_static_assert(expr, msg, ...) _Static_assert(expr, msg) +#define kvm_static_assert(expr, ...) __kvm_static_assert(expr, ##__VA_ARGS__, #expr) + +typedef uint64_t vm_paddr_t; /* Virtual Machine (Guest) physical address */ +typedef uint64_t vm_vaddr_t; /* Virtual Machine (Guest) virtual address */ + +#endif /* SELFTEST_KVM_UTIL_TYPES_H */