From patchwork Mon Sep 13 20:49:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raghavendra Rao Ananta X-Patchwork-Id: 12490755 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 4EEA2C433EF for ; Mon, 13 Sep 2021 20:53:11 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 22CFB6108B for ; Mon, 13 Sep 2021 20:53:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 22CFB6108B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rFaZ2YWzMGg6BMFmUj3jf3MOcZ1IXkkg+SJOVTDe0aI=; b=VHStrJ02I0BUT9dE008H8xa3ZQ HjbcqITKGV+LIOzwNEG1cuXcetfiLbcG2qnn5XML95WabLMN2fxLlnoJvUAD4+aAFVUNI3RZ6EvLA 5t0ocbn0EyLywAafoG+E8W42fi9Flct9RuABE/4UJTbiBXf0feFaVBBWV6ojHs5wQjw/E84MvXi5B RMd0qTiwci8FBh1BiPI6ORXEIt3S7I53zWoheavnVkn6VGRa7CiBXJLAXLKVxzkHTXErmK8QAb++a uZMKExKHc76rwL/9ComkHhkch8qXU3tcN+n1ebbTkSDQm8bSN027V4hhL3MLK4m7EzR1Pi3LiFeI1 wJCYb/cA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mPsu3-003BpR-NL; Mon, 13 Sep 2021 20:50:11 +0000 Received: from mail-pf1-x44a.google.com ([2607:f8b0:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mPstj-003BjV-Ux for linux-arm-kernel@lists.infradead.org; Mon, 13 Sep 2021 20:49:53 +0000 Received: by mail-pf1-x44a.google.com with SMTP id g5-20020aa796a5000000b0043de84dd952so1440011pfk.11 for ; Mon, 13 Sep 2021 13:49:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=z0+JpyYfhLSjBcBB8p9fMALyI9F5+XNuowwy7CcZMnQ=; b=UTByguEDslH6iAVfogjn3qnb8AWd+6tBKg0378q6FR9CLexbMhAnEh1UmUSMKERHbE a3ifJ3I8atl6Ms7aJMzTLErHT23zkHSkFKuRSx6888qG/LQ8t6vw6f8KCmh8wHjY/OMM KV8vr/UUoCyc4W0Joaq7y/WnkzncmJrzysCECKRnBV8IyTrSnlXUI6xhNgaI3i3rQFPW 9vyDUa0JhT650jjBpR2WbLp5q/vL7InCsSkIQW1cZJg7FyZliV3DV+oPBSWc36Fmui8b k1ecqd3g1Fedlxj5dtMhDkJA5XSNQyNToGFwYFgqAQVH9ABLx2PRkZ44ow5GtSoL2JVn bO8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=z0+JpyYfhLSjBcBB8p9fMALyI9F5+XNuowwy7CcZMnQ=; b=UtVEw6T2zfAm1nvwCTtVGhE1ft8PcO8rKF4y9+CleRjujf7x7zITTrDGtxJzZsj8gi fW3S7JXmMrXVHPf22uYAR88nA1ilLBkxEcn7IWocsQB3t029mPOWNkeMZz2xpWL9KrEE TeokR0K5dIcZF0qW1tKp8so/Ybd5C0p/RHCoNflD/Rsk/h7ql+YpMWVVmCVfkgJmpAOj PRAj4AmZZgYt9tUJFa1PvfCKFTf3pP5YTyb1ps5/aehg+ogP9f7Hsst1pmdPZUpmYLAY cs4i/xMCcbuq6pRaZhK4Cyyd02wwK+IfCe7A1kzMp8VfdNba1Bd1KQoUmU3qDMKZTEee 9nXw== X-Gm-Message-State: AOAM531Uo3N8C5xdST88rtU+tVRF3Z3h4VWCAtm0iwQtVDNNMrtbgG5w A+cFHoC0GaYAJZ7JUrBfpWhWjWccRpOE X-Google-Smtp-Source: ABdhPJyKu7ncprozIHJ0z1BZxP0TRGCJwO7KxcZgSVnDKki6dwTjJwMcki3jTQOnPHBtNg6lhzG8oD9W/orG X-Received: from rananta-virt.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1bcc]) (user=rananta job=sendgmr) by 2002:a17:90a:a513:: with SMTP id a19mr1632405pjq.26.1631566189354; Mon, 13 Sep 2021 13:49:49 -0700 (PDT) Date: Mon, 13 Sep 2021 20:49:19 +0000 In-Reply-To: <20210913204930.130715-1-rananta@google.com> Message-Id: <20210913204930.130715-4-rananta@google.com> Mime-Version: 1.0 References: <20210913204930.130715-1-rananta@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH v5 03/14] KVM: arm64: selftests: Use read/write definitions from sysreg.h From: Raghavendra Rao Ananta To: Paolo Bonzini , Marc Zyngier , Andrew Jones , James Morse , Alexandru Elisei , Suzuki K Poulose Cc: Catalin Marinas , Will Deacon , Peter Shier , Ricardo Koller , Oliver Upton , Reiji Watanabe , Jing Zhang , Raghavendra Rao Anata , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210913_134952_055473_CB78F20C X-CRM114-Status: GOOD ( 12.36 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Make use of the register read/write definitions from sysreg.h, instead of the existing definitions. A syntax correction is needed for the files that use write_sysreg() to make it compliant with the new (kernel's) syntax. Signed-off-by: Raghavendra Rao Ananta Reviewed-by: Oliver Upton Reviewed-by: Andrew Jones --- .../selftests/kvm/aarch64/debug-exceptions.c | 28 +++++++++---------- .../selftests/kvm/include/aarch64/processor.h | 13 +-------- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c index e5e6c92b60da..11fd23e21cb4 100644 --- a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c +++ b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c @@ -34,16 +34,16 @@ static void reset_debug_state(void) { asm volatile("msr daifset, #8"); - write_sysreg(osdlr_el1, 0); - write_sysreg(oslar_el1, 0); + write_sysreg(0, osdlr_el1); + write_sysreg(0, oslar_el1); isb(); - write_sysreg(mdscr_el1, 0); + write_sysreg(0, mdscr_el1); /* This test only uses the first bp and wp slot. */ - write_sysreg(dbgbvr0_el1, 0); - write_sysreg(dbgbcr0_el1, 0); - write_sysreg(dbgwcr0_el1, 0); - write_sysreg(dbgwvr0_el1, 0); + write_sysreg(0, dbgbvr0_el1); + write_sysreg(0, dbgbcr0_el1); + write_sysreg(0, dbgwcr0_el1); + write_sysreg(0, dbgwvr0_el1); isb(); } @@ -53,14 +53,14 @@ static void install_wp(uint64_t addr) uint32_t mdscr; wcr = DBGWCR_LEN8 | DBGWCR_RD | DBGWCR_WR | DBGWCR_EL1 | DBGWCR_E; - write_sysreg(dbgwcr0_el1, wcr); - write_sysreg(dbgwvr0_el1, addr); + write_sysreg(wcr, dbgwcr0_el1); + write_sysreg(addr, dbgwvr0_el1); isb(); asm volatile("msr daifclr, #8"); mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_MDE; - write_sysreg(mdscr_el1, mdscr); + write_sysreg(mdscr, mdscr_el1); isb(); } @@ -70,14 +70,14 @@ static void install_hw_bp(uint64_t addr) uint32_t mdscr; bcr = DBGBCR_LEN8 | DBGBCR_EXEC | DBGBCR_EL1 | DBGBCR_E; - write_sysreg(dbgbcr0_el1, bcr); - write_sysreg(dbgbvr0_el1, addr); + write_sysreg(bcr, dbgbcr0_el1); + write_sysreg(addr, dbgbvr0_el1); isb(); asm volatile("msr daifclr, #8"); mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_MDE; - write_sysreg(mdscr_el1, mdscr); + write_sysreg(mdscr, mdscr_el1); isb(); } @@ -88,7 +88,7 @@ static void install_ss(void) asm volatile("msr daifclr, #8"); mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_SS; - write_sysreg(mdscr_el1, mdscr); + write_sysreg(mdscr, mdscr_el1); isb(); } diff --git a/tools/testing/selftests/kvm/include/aarch64/processor.h b/tools/testing/selftests/kvm/include/aarch64/processor.h index 96578bd46a85..7989e832cafb 100644 --- a/tools/testing/selftests/kvm/include/aarch64/processor.h +++ b/tools/testing/selftests/kvm/include/aarch64/processor.h @@ -10,6 +10,7 @@ #include "kvm_util.h" #include #include +#include #define ARM64_CORE_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \ @@ -119,18 +120,6 @@ void vm_install_exception_handler(struct kvm_vm *vm, void vm_install_sync_handler(struct kvm_vm *vm, int vector, int ec, handler_fn handler); -#define write_sysreg(reg, val) \ -({ \ - u64 __val = (u64)(val); \ - asm volatile("msr " __stringify(reg) ", %x0" : : "rZ" (__val)); \ -}) - -#define read_sysreg(reg) \ -({ u64 val; \ - asm volatile("mrs %0, "__stringify(reg) : "=r"(val) : : "memory");\ - val; \ -}) - #define isb() asm volatile("isb" : : : "memory") #define dsb(opt) asm volatile("dsb " #opt : : : "memory") #define dmb(opt) asm volatile("dmb " #opt : : : "memory")