Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1836474pxb; Thu, 7 Oct 2021 16:36:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1B3U/mwLMxQoDRsox6HXojcrLSFQPFrEd9eFQm2g4UPwaSJoMTB2MIniP7SOLvUul5Og0 X-Received: by 2002:a50:9d44:: with SMTP id j4mr10466325edk.173.1633649817623; Thu, 07 Oct 2021 16:36:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633649817; cv=none; d=google.com; s=arc-20160816; b=p5VA05u6lUt+vKvfILqXn8SEqbTLoDWkuij4HHDrs4ly7yGc557ZiMjWl2S1qeZCn2 dBRf/ih1Mm5SkuWq01aPd8QaQh/1Kl1eNYUB8yNMI78R0BIyOJFPZf4LRtNDAFD6BJht X0VcOzrKdp/rdPKGlJUrQ+9L/o/C2W/HJRnypt5D4edbJnhLDom8AAnJn30z1Mop0avB xmiLPJsEMYtb2kKD1I02txlOf2dTPSy8JdOKH76FUYYcfByiREAGBTKpJ+3wCvvTgL9R CZjwk3cgQV+xXSmdYRpopuaVWBefjvkL6yNTVPg7fc5r46oquel09at4L7NHFzcdpFCY Dt0A== 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:dkim-signature; bh=M8aqW4xDV1zEpWZcgiAXX0xgC0wnS0Pw0xPZD//h+5I=; b=Yjq24TF4QP7yFHUoByJnusN0FhxgHgVVes1C/anCrQUVzkngQ/0L+VpB5iXn2oQC9i IT9uv/S21ef4bySU9T7ZXaX+6vvTlwjXcDrUbFXofTKZKJhNhzEXDqZywbgqhstd1kPD iSrK5x6AhsmLuzGH4v6s+8f1zbrWN6bWJEAQcvLuq6C9bwGWyJBM52BWElFvwIcKmw8f R8EuYZOghQHEskUYHmU4Bzo6uUrVV/Hyfo8lS65nETV1yz5F1SyHpxJ5hpfC+tgJiHsQ bz30PkkrGWnJmI8yNGuLLH4VdZHyn5chL8DijcVKuHN1xRHa0fthxsfknXs026/MF8Pa avvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=cDnANgpf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g18si987203edt.383.2021.10.07.16.36.33; Thu, 07 Oct 2021 16:36:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=cDnANgpf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241607AbhJGXg4 (ORCPT + 99 others); Thu, 7 Oct 2021 19:36:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241061AbhJGXgt (ORCPT ); Thu, 7 Oct 2021 19:36:49 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE8E1C061570 for ; Thu, 7 Oct 2021 16:34:54 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id y16-20020a2586d0000000b005b752db8f97so10000605ybm.18 for ; Thu, 07 Oct 2021 16:34:54 -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=M8aqW4xDV1zEpWZcgiAXX0xgC0wnS0Pw0xPZD//h+5I=; b=cDnANgpfF6yPTWt3MKnNLvUOhi/n9MnPCidZweGjwJOW2hnqzfa7S1o8RRmhGS9ofH sbSg/JV+6lAMq11oHtGm+SAoYquMvoV0JVKvPGdwQtvp8Kp5rrlMjBB4rcp2wkes3mlI rm986u+huwg79G9aNg3c7q2RUICjxytAUhLQ0qi5dFVOzgi3MLbX/YyfnaSaLtWS0V+g S7k6yXxnO8WC5ndRQ2Sba6vHRE2UA6/3ycPekuWphOmGaZBjD9Rb/iHkFG9mM5+e5pCh 8t8Z6HffraMq4fQs51NFK+Mm7nQqH8Kg0ce49LGSLqtsg07iWADgruB1FEbJBQ94Igr2 NteA== 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=M8aqW4xDV1zEpWZcgiAXX0xgC0wnS0Pw0xPZD//h+5I=; b=4c2ZKtO0ZZ4/Vh9G8sEjbcVnwFIHobhdt1fHqx+nl3wWu378aThoAegWpYqDvV1vd/ lcu/f/vh7RU2gwSW5Zer46sA8722ZazeofpDVMjzhKN+OHgvKs6DCR5hnswzhrJF68n0 vgopurQh0smxFxMGaFJ7f25lxEGDI4cEJKxn5MQyHm33Wr/6hB4BwJdn0hZt3kALBI2J adS7Sn0Jo9J6NcZBQSbxj7Rz4CGAzpNqKkVzHIOqfwRavWBscC8yWEkg3egayhzM80qA hj3M738H/qZv0aQJJGTwEGJmB8mN/KAKQLe6J6BE4E1XJ4iHLLpsdwogo8xg4MadoW6c M7dA== X-Gm-Message-State: AOAM532nM3+EakO6yTMV0Mr7KTysGpAW7aV00W4hANGI+aT5Vq0kWP9d fd7KGgzH0lTqMySWVP8by4CyU7s/vEPt X-Received: from rananta-virt.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1bcc]) (user=rananta job=sendgmr) by 2002:a25:dc4:: with SMTP id 187mr8511882ybn.497.1633649694139; Thu, 07 Oct 2021 16:34:54 -0700 (PDT) Date: Thu, 7 Oct 2021 23:34:27 +0000 In-Reply-To: <20211007233439.1826892-1-rananta@google.com> Message-Id: <20211007233439.1826892-4-rananta@google.com> Mime-Version: 1.0 References: <20211007233439.1826892-1-rananta@google.com> X-Mailer: git-send-email 2.33.0.882.g93a45727a2-goog Subject: [PATCH v8 03/15] 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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") -- 2.33.0.882.g93a45727a2-goog