Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp253299pxb; Mon, 13 Sep 2021 18:27:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYQaqmn7651slsi/VoivZr4OHhVYZ/C/29icqbOGjQlMzwc5q7xa1p+LddW3tzeslkQQWS X-Received: by 2002:a6b:6613:: with SMTP id a19mr11515019ioc.167.1631582840168; Mon, 13 Sep 2021 18:27:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631582840; cv=none; d=google.com; s=arc-20160816; b=TXLl0AV9cmQ0oKLOnmo0aCd4Z5dEQVZCOyrYLqH0MoAvq5f3kxMSxewhD+oGv3VbJM /dMwM1K5adEWu0W6aYKoV9ZHW2jZqlbztahazqnrAF8wbjRH55ermQPRS0zNwXFfqAcU 2+sdncgUY1Pj2gesKTmwafRxBH6+tCCcI7UWuQdy2QPHQOS1Rlt50iHx2tLQsALD/jiZ Z258mzWIhZoaoMkp4Kt4BPQPj+ERTMusEM0iNRKkDrvcC22ad3GHChoR8pr/dJ+c1/9e woYnwFXT6Jc1qo678KneBcWtHzV/6xnm9Bo41ipEdj47PCYTPWDWxc8Pp2x/Qcumw/eE QUUQ== 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=z0+JpyYfhLSjBcBB8p9fMALyI9F5+XNuowwy7CcZMnQ=; b=oV9vpBCxIPmmCFMdeV0LiThHG/tn4XcUAqkvjWTmERBIN9lcTQ9d1fPqpW+k2ltjdU HP6LOnCpnyqGXBCSgZkrnp8tsbxa2wafWcxPQvulXrulWG0oWn55hJGHl/N02DN+Lz1P r8iObFRVSFZAS+4MD+4O49U53z1T2junFySwhrNMDDyB4Tci1CO/g2A6WEB0AajlcLv5 RQH3XjWp+sUjuN+T/WQJfGdIix1M6cOKjQt+VcOJ0JNSK4AzfbYsXr/eLjZOLPSdYp1e BpIdVMRz52CfP0rFz148rBJ6qCFsGz9kjqFbCrHKUMFh4k0JLKW8V86vH+B8yqXcEPbW 7R9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Opmmtb2y; 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 k35si8275062jac.46.2021.09.13.18.27.09; Mon, 13 Sep 2021 18:27:20 -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=Opmmtb2y; 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 S1343612AbhIMXMx (ORCPT + 99 others); Mon, 13 Sep 2021 19:12:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349441AbhIMXL5 (ORCPT ); Mon, 13 Sep 2021 19:11:57 -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 7A273C0613D8 for ; Mon, 13 Sep 2021 16:10:09 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id f8-20020a2585480000b02905937897e3daso15097014ybn.2 for ; Mon, 13 Sep 2021 16:10:09 -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=Opmmtb2y9hX4UiFubg2umOXf9A8zlstjekSEQUdfcA8pXArF6B10BpHHQR1U4CTYqp T6qKN7K5PhB+IXl7mfg7JSvgNWVrtpgMKX2nOWsKd+iRFRISa5Ma5M0Ujh6jqZCLjwY6 TbSf25Ve7zmM/3k1bsXLuRwK9uzWz2PPFe4LHAVVfYmF2qTwKtz2Fm74ufFPQliQNaJ2 RLGZs7kA8o6vwcYH8nczAopY2wRRyLakoxnPVi9N3B+9JXEYOjS3feN/+fBpuIF+cReC VUjs28vBZfIyE2Ee+3WAOkJ6kQCU3m9+JQOVpHLVOdNz+ZS7T2ZVfuI4zz11z4GHOXxo HQww== 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=xe8DDlZODHuH0A1TujnL/Q3DdjyaeaxmQYC0jkCHBjrpDpush7OfsmynJhTfH49gqW v5L420uoJpCsT88DEXrxzGz3P2N/tRRg95iZSGE9Rw8C8LPwrKeZ6NebsnoZ9BJ8StVA g0vNrZObs0KZVggg66l59AX2bngwSuEmrbEVpVdFE7OA12RVdCrQ/sJX1Lmfn0a7xfoI lZ/ZL0eM6lGbG+JsBIdUNLWABvIunLAZj3imBd8FWlAPF+U2Rjtk/7dcucCv2jdW1rOF zujziPdMAjdO3OoSGvGiLXjQ/Utfx+rstlBIqGGkzjWUItLXLCvV+D5B103xkjh6xIVZ HrsQ== X-Gm-Message-State: AOAM5310JmIRUdGJg86/2cJbuuk8tZ3d6OwNrGz+eqWv/QM+nrkUDZFl 2J1FwpBRno6iATQJMBosjTojQU2pv5lG X-Received: from rananta-virt.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1bcc]) (user=rananta job=sendgmr) by 2002:a25:d8e:: with SMTP id 136mr18171293ybn.171.1631574608707; Mon, 13 Sep 2021 16:10:08 -0700 (PDT) Date: Mon, 13 Sep 2021 23:09:44 +0000 In-Reply-To: <20210913230955.156323-1-rananta@google.com> Message-Id: <20210913230955.156323-4-rananta@google.com> Mime-Version: 1.0 References: <20210913230955.156323-1-rananta@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH v6 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 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.309.g3052b89438-goog