Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp721790pxm; Fri, 25 Feb 2022 18:18:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFM9cMQvqh1CuiGPrNyy5wEMpKtRsQsJWvgHVBHycjqixB4CGyRBjb8RoU5y2iDCrKdABW X-Received: by 2002:a17:902:f54c:b0:151:4cff:3f28 with SMTP id h12-20020a170902f54c00b001514cff3f28mr97553plf.125.1645841924284; Fri, 25 Feb 2022 18:18:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645841924; cv=none; d=google.com; s=arc-20160816; b=0Igk0qcb21pIPSnhcjnQUSGDnR6AIp29u8sl/K3mmR+XCOhdmxit9h1UMgAwQNmHZ7 /8+Tpa6Ul6InpOlJ3HR7SRJDxAvc0RDnNBvzKbv0116jevKNhr15gUp8MDcXPvGp4aXj KBVuI6KNr4cVsGWDZEIzLGya+txA0A2xNFMbfhFJqhQdgUXbxQ7x+lC4lTSmTNHRnXUC C0/1qmcFMh65efdYwjWf0L7mgjTrqj2Qa66cxqrM3CZGuXiBGFnw/zQS1Gk3Eu4P+869 KfLoTA+AuV1FpAaC8A/jgZKJTHz3wUCZHdD69uWx+tYR38FE/AvRqCCplg26K0aw7k6c ttOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:reply-to:dkim-signature; bh=eZ6FrXYp5R1CiB/zutWVqNTtHVIMJ9iK/usaw7re+ZM=; b=rGYTtKXCaOrPRcKQCY85B6bADJJ5HsYdiS+1ZieoGYAS6BSuzs6+Nf5tWSr7LfNiEu 3zokFJ813+gegVSbG7WNa25UJYPTwac+a1Q1TTdFIf63etpb7xYx1GcjqFP6EDRyNi7N rrxnLNY2tHtcJ9hb6m+U/hF7fCxHDhPWf5c1GJLgu10LXnZwlv+5mpDPSXORG9mP2SAT KYor80Yw1ceSddjZgA3myJ8MtUW9Thbbf40Cen3APkxEREXBuGyzATMZbuIanYerclop TgG6VDL87J0NKcXAt30yvnVnd/JVXZdzjcKetcbpggiA+/Zed9OU1bGSgOAkR4vD0i2A 82bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hl4rpFhi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id o19-20020a056a0015d300b004f2ea796a2esi3807227pfu.84.2022.02.25.18.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 18:18:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hl4rpFhi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 761012668E4; Fri, 25 Feb 2022 17:51:18 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240902AbiBZASq (ORCPT + 99 others); Fri, 25 Feb 2022 19:18:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241490AbiBZARz (ORCPT ); Fri, 25 Feb 2022 19:17:55 -0500 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E44CD234039 for ; Fri, 25 Feb 2022 16:16:56 -0800 (PST) Received: by mail-pf1-x449.google.com with SMTP id k130-20020a628488000000b004f362b45f28so3967041pfd.9 for ; Fri, 25 Feb 2022 16:16:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=eZ6FrXYp5R1CiB/zutWVqNTtHVIMJ9iK/usaw7re+ZM=; b=hl4rpFhiL+jXYPutqrx0t6H9bf3KWGfYlj27fcEIS4FHVk2BLJKj160C755dQet0Om 5wKQ0jzn+T5sVODiQ3ZVUFHquVzV4gTyXE1RAGwfmiNCujdwofwFLe67wnXAwY3ijDky 6SOhAc6xWzGXY2bLPyVm02FJWPuCr90UPEKlq6cMCQPphEEo9LBJWScK66QVyzou7qc5 4ZmdsrFTu6j72r1Bz7uS+S46URV1CD9jrUh3nSS5KFhoixty4Wr8AgwFKpu5RV+sqjz+ u1EMjoVbVh8eUyq40oxulkA2xXnztTkZBRfq7UC5YNTfkYaybbE9PZdge8FPKML8hwGy x+Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=eZ6FrXYp5R1CiB/zutWVqNTtHVIMJ9iK/usaw7re+ZM=; b=Kv4PpF3ZXoK20UtiZQA8PJLDQEbSg8bKwxN+/oc6GHD52D2CLL8jEiWCP6kQZHnuMK svA2Zvujd49pCQnu4ADZ/2UGw5ftfhyCP0GODzq++zT+56dSi/nmZy5KSWczX3/vMHjd hRUpFExS6DCHbNfu1srtOIK0L/ayGu0U74Q89DAYkreKY3M6u9zXVsLpUf2WnP4TlLVW gh82PSXRC/JUbiEI2LYJ93rRA2/czjGl9knJzJTQ5Q2+Zm8USjMTfhxVkSMRSdzxuSYS mk2NO+ZZ/RvUmTSOZjtkEiNEZtYUTI1TIwashiqMMQNr5Cy401ofDjBou53tEOo+Dt5p Eu5A== X-Gm-Message-State: AOAM530wZaeLK5sv5ZchdFL2NyP96ywJhmOZarQJKYDcF749ubSqzqIT eObnNG4qkwULMfvhs9pFJ/T15bgRemw= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:902:bc42:b0:14f:e6d0:fb7b with SMTP id t2-20020a170902bc4200b0014fe6d0fb7bmr9397561plz.127.1645834606838; Fri, 25 Feb 2022 16:16:46 -0800 (PST) Reply-To: Sean Christopherson Date: Sat, 26 Feb 2022 00:15:45 +0000 In-Reply-To: <20220226001546.360188-1-seanjc@google.com> Message-Id: <20220226001546.360188-28-seanjc@google.com> Mime-Version: 1.0 References: <20220226001546.360188-1-seanjc@google.com> X-Mailer: git-send-email 2.35.1.574.g5d30c73bfb-goog Subject: [PATCH v3 27/28] KVM: selftests: Define cpu_relax() helpers for s390 and x86 From: Sean Christopherson To: Paolo Bonzini , Christian Borntraeger , Janosch Frank , Claudio Imbrenda Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , David Hildenbrand , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, David Matlack , Ben Gardon , Mingwei Zhang Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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 Add cpu_relax() for s390 and x86 for use in arch-agnostic tests. arm64 already defines its own version. Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/include/s390x/processor.h | 8 ++++++++ tools/testing/selftests/kvm/include/x86_64/processor.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/tools/testing/selftests/kvm/include/s390x/processor.h b/tools/testing/selftests/kvm/include/s390x/processor.h index e0e96a5f608c..255c9b990f4c 100644 --- a/tools/testing/selftests/kvm/include/s390x/processor.h +++ b/tools/testing/selftests/kvm/include/s390x/processor.h @@ -5,6 +5,8 @@ #ifndef SELFTEST_KVM_PROCESSOR_H #define SELFTEST_KVM_PROCESSOR_H +#include + /* Bits in the region/segment table entry */ #define REGION_ENTRY_ORIGIN ~0xfffUL /* region/segment table origin */ #define REGION_ENTRY_PROTECT 0x200 /* region protection bit */ @@ -19,4 +21,10 @@ #define PAGE_PROTECT 0x200 /* HW read-only bit */ #define PAGE_NOEXEC 0x100 /* HW no-execute bit */ +/* Is there a portable way to do this? */ +static inline void cpu_relax(void) +{ + barrier(); +} + #endif diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h index 8a470da7b71a..37db341d4cc5 100644 --- a/tools/testing/selftests/kvm/include/x86_64/processor.h +++ b/tools/testing/selftests/kvm/include/x86_64/processor.h @@ -363,6 +363,11 @@ static inline unsigned long get_xmm(int n) return 0; } +static inline void cpu_relax(void) +{ + asm volatile("rep; nop" ::: "memory"); +} + bool is_intel_cpu(void); bool is_amd_cpu(void); -- 2.35.1.574.g5d30c73bfb-goog