Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp100359pxb; Wed, 8 Sep 2021 18:41:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylHdt7LFPkC7j/+AX9BMgM/5sezTNZKY5pwA2ocGKaXPBzw8E0roWg+PtId5On877KUO8K X-Received: by 2002:a05:6638:2728:: with SMTP id m40mr476050jav.141.1631151662082; Wed, 08 Sep 2021 18:41:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631151662; cv=none; d=google.com; s=arc-20160816; b=BfYQ/mX/Fj1/FJbNMBP92IHKUT1/KSIpTwJoIcbirJborxeDENNMiYnDLjQ9CI7jWF LBvHYLGjA8nDmyqn2h2QXIczItMlt1RRTckOsMV/1Zzcl5AaB0kmvgfcD9nmoUlT6qGr DqDFbMyld3wV+RmbNLah1YpJ4ypyaL9bog4/jSj7kc6sjYW0voUpeVTmSmo50v4+aESz y7Vof/PN/CkcbtNzjz6L6MwBer2gKs+S26iASkEP3wu1YKajYRb2TXLni/0XSeMs9L0v qdkCDurQjQn0rez6dgNGWcW5AAxjVI6fOlWj+/ItI4sVFXrZOk6mI5SRYedA7M9tUMb5 gW9A== 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=AmUNmW1zNN82NWDCZCOv1ajU/78+UJITtNZym/5TLfk=; b=Kz/Z4qChDhOalBT2uZpO1O8LPxS1T1CYguyzdUjS0EL2C+Nz/TS/+wXBGPM6k58NcT SmGDkdbIQTvAl0hRWavG6I7anXGatXCbHfRO8gkG4WCEfTkzjZPYq2ZKTZJGmYb28wEr yrjo0nANYaKRbwA9qqT1W5mdJev6X2+DYZrnYFCZDRNUFmoA9NXvnRp5Lx8xx38aRQum WT6eOXHAmjfNx1Z08cOxsMgplFYufytmn5g9GtrNbLCS0C9kOBTNS5JgjpCACIl4CPnY /FGhL7nCY/QZ0kPVb5kCE9IrK5Z8GB5HzJqPdC+QOHUEpll2H/hOsklEt2qYZlIi3K15 EvyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=nVLRqzD6; 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 v18si327842ilj.94.2021.09.08.18.40.50; Wed, 08 Sep 2021 18:41:02 -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=nVLRqzD6; 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 S1349425AbhIIBjo (ORCPT + 99 others); Wed, 8 Sep 2021 21:39:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349374AbhIIBjl (ORCPT ); Wed, 8 Sep 2021 21:39:41 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B346C0613CF for ; Wed, 8 Sep 2021 18:38:32 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 124-20020a251182000000b005a027223ed9so387573ybr.13 for ; Wed, 08 Sep 2021 18:38:32 -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=AmUNmW1zNN82NWDCZCOv1ajU/78+UJITtNZym/5TLfk=; b=nVLRqzD6wmqrvZ7NzKkwjTUiJua5Ei6ADvZu1xGt4iE5FUDbOxGNmsNlVUqk+djoq1 oU6mj2WrVuYDdr9KTXNHa+nyASgxa29IHf2VIQ6Fnl3TgQmZiBiozmJVSwDqw4sIiTB7 luu/462mdgVrDsXpZO71HDSayore8Y16aeYYJZ+2TERLRPHJgAiSbWINpP22ZdSRYXHH IgFkvfSQnyZtI99PM3ia16/uLcBfn3nJ7qBqF2uiyIMAq+PBrMDUq/E1h/GQ9pTDacYn 2UeMfEjtC9bugHyi6PXpoyqVTIxDroIpEu/6Zlz/FSvPPE1bMRkAODU8HzUr6ZAUAJiE +mPA== 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=AmUNmW1zNN82NWDCZCOv1ajU/78+UJITtNZym/5TLfk=; b=tGLUbtp6ZlqIkTzTDzCuPl9bBg9LDfx5nx4ysw4N0X/VA9IUoLvcZQKrIcik9RyfbR wY7aVt8nqWWKxXZwttH7Ppk+t1ptBnx7IRifUeSY85lEe4Tynpnf/l3SONlY8KYEn+f9 g+gU0yz8ePb4u0yc+Q1yKulnODVW0Hp2S5GM8G4BH1rGteF5znObG8NKy14sF3paf3yN MRO/bDmrKUYQ5UGQtmzK9Euidzru6IKZ18z0pjV82SSvbuXsGn6RAvtk4TJLMrGBl1OK 7z20kyvIpNJz9b6OwOWJHkUzPWjffcfigrCzdkcOGJWmDq1Y3mUlVFKXbf3nmK6kCFHd fHGQ== X-Gm-Message-State: AOAM5325FboXWvmwu7wAuPZs8TJWrbRuyGgWq+QxHoUtyx2eWVM6vm0E Bhp4JOwvI+Ds76FutUqQaKN7AlJTnkBF X-Received: from rananta-virt.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1bcc]) (user=rananta job=sendgmr) by 2002:a25:804:: with SMTP id 4mr522844ybi.346.1631151511813; Wed, 08 Sep 2021 18:38:31 -0700 (PDT) Date: Thu, 9 Sep 2021 01:38:03 +0000 In-Reply-To: <20210909013818.1191270-1-rananta@google.com> Message-Id: <20210909013818.1191270-4-rananta@google.com> Mime-Version: 1.0 References: <20210909013818.1191270-1-rananta@google.com> X-Mailer: git-send-email 2.33.0.153.gba50c8fa24-goog Subject: [PATCH v4 03/18] 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 --- .../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..bed4ffa70905 100644 --- a/tools/testing/selftests/kvm/include/aarch64/processor.h +++ b/tools/testing/selftests/kvm/include/aarch64/processor.h @@ -8,6 +8,7 @@ #define SELFTEST_KVM_PROCESSOR_H #include "kvm_util.h" +#include "sysreg.h" #include #include @@ -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.153.gba50c8fa24-goog