Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp242580pxb; Mon, 13 Sep 2021 18:08:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1/G4BdrTCNGvPGIasAUtwIW9B9UA61BsMcaQWVCebtTsDRD3hAzFIy+POt0UlBTRUR8HV X-Received: by 2002:a05:6638:381d:: with SMTP id i29mr12337088jav.29.1631581723308; Mon, 13 Sep 2021 18:08:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631581723; cv=none; d=google.com; s=arc-20160816; b=Szctk2SVTKfLdGzzJNMwlH5lmpY1fZuQzc7Idbi8dYVJNERAQXRN0BkpFDvyb909Mw hKIscLzoyvDYVTqdH/00IiCiZnEKUQlt5UZfTlBQs7W3z0h/tshhI5eskSKrdTHvh1b0 umuOPkTotsxnRbxqYVoa0BwvmnME9XTufAghRVDnFwJExRhbZxqw7CEkcZe+umruVQ4r /IuMhmtnnjoNzINTPK/XlTUIj03/3CB3ML953IcGLfhHHMRChxaccteUacNa+VIsX278 eYoqg+7XgAw20GyBAWsF/zmqu5LnMax55DHj2r7kza8lp6enOgxjlVICw5puSx5Z/Kjk AoFw== 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=0lc2rR25yzVmlg0xcpWmdJxIRVEet13pFKbxtlWp6jEPry5+fiM6Dad845m8bMilMN VuBqG2LRxd7fGxZK6ZtvtF24nUwTZcTSu0ai6hyLqFwZC4P/f49OBeURHdw9/+5bsKVR xEYtrY6BrLW0HoLHCYCSi+n9zB4ba4f5C1Gcse8Fj2HBFmpFAebfQp+RkRwtmRlAoOFk vVlOCLYaKWjT4eM8wkoVyXrLvx8TPJmkQB6chrESlrVH/NQhUO2b7I21ka5RbSJ3fTD9 N9en9ogO4i7vfpnKAJ1yMckJ3pX6b2fjbbht7WjVRYTqRcL35VZYj8B+/2hQzE34qjSg dQFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=UTByguED; 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 j8si656494jat.1.2021.09.13.18.08.31; Mon, 13 Sep 2021 18:08:43 -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=UTByguED; 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 S1347783AbhIMUvb (ORCPT + 99 others); Mon, 13 Sep 2021 16:51:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345293AbhIMUvG (ORCPT ); Mon, 13 Sep 2021 16:51:06 -0400 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 68E09C061760 for ; Mon, 13 Sep 2021 13:49:49 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id o130-20020a62cd88000000b004053c6c1765so6888428pfg.6 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=ncqL6Xn2xHPbdJmLsMZ3ksMhuUDlb9XYA/QXT8PtRWuO1WMTsxVs4sXsHPkTdoQqI3 5m6I/hTZ+vm+CiumW0p/RvlhuG9tr1yH1QoVklgvllneqBt+j4kCU0SrrV6XjjnR4YFf S2ueHBzMS58hQRJ3AX65SmV+CQSG9H0Fje7eCR7aiTAw4axdsNZXQZrJvHjhwdWWJsL3 YqMDLi/2OZtXYrRIhiFqkKiuCr53qQWBa5FyhrufIA458/z6shBY0Jk5Cf5DrT5Np73i c506t2neD5VuuMYt9oHyAxmJVgThRUrdaRylvS/U8JEF3TRCsbYpva704JmEPKDPARki tzFQ== X-Gm-Message-State: AOAM533bVDflUmSAzo0NkQEJhrznYlPoMnYobHjFG0wTmimdx0yKodm+ 8FSG9hND4HYqk9S9NMU4ZB+oIeyHtYFt 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 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