From patchwork Tue Jul 25 08:41:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 125437 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2340701vqg; Tue, 25 Jul 2023 02:17:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlFpuomkBvDmEIGb2nWMgzIyqPN9Ae+O/sAM/ST2W7grnzSKJB0r25bjZBuQPi5M4DNAcl6P X-Received: by 2002:a05:6402:613:b0:51e:1a47:3e3a with SMTP id n19-20020a056402061300b0051e1a473e3amr11047167edv.18.1690276671237; Tue, 25 Jul 2023 02:17:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690276671; cv=none; d=google.com; s=arc-20160816; b=qJOE467v+2jTlqTAxxtzu5OreXIGcPpQNVxyFn/5Q+3sCnO79Jl+PXUrP0KtsKkOTJ 9VSVasRvAVrxMM0EXFlUzWmnb5oLEePQAd+fSpxOj7iMZGfgaMT42bCZt5GfH8c84815 CrtFhATLaQCTC7RABXI/ksbjjQW03sydqaTFZ4wGFYxr/wjwkdAqM60Y8qg/c3IQlFdk dTfw0glZ+6hrLhZLrSbDCkddghsZysBpIi/7sYXV8j6fMvrKnkurqv/E03x8AQkeacWp bBoGjIMa5JE7R6BKqW+9qzZZYP9NwleN8cb8/W6lNuilAA7zRfcqdQDG3drzTZpbJaSZ heog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=8TOPTUXEMT5w1qQUeWgE14TexdHWMvm2+iiruAV5L/E=; fh=XFcXccLY/Z9dKqsvNiNf7RRScAl3y6nQUvlarJE21j0=; b=F3I2Qk8u1lM9OMnwuT9/Sq1xnXLIIn2AEJ0Be0AE6h/fej7qzyjFiFSD6gD4YnyfLs oit259Oh3NTOBfkVrIyO1DECymVwh/S4mtC8XaZXibh1Sibo6ywaJQpMSnk2L/cIn6xE 1ZFZY4f9cwnTfe27TSCdJVj/2UQ0qpM4gofsWE2mjIXIYAxCPKXk2O8PbdAoml79cXRx 9c1XFwA/E6Uew3gplqRjTK23EgMnV6pEq4p2xAlmJWmu1jXD35uYDzp/5QYQI86eyLj1 FHlbpUrZ7kamayEoVGaNy/XmXxidDCk9IYjB+4fHW/H0mLz4K4+AE+Ug/Jw/LiG8lao9 cuWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=jSteRh7B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g16-20020aa7d1d0000000b005222fd5808asi2684277edp.276.2023.07.25.02.17.27; Tue, 25 Jul 2023 02:17:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=jSteRh7B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229475AbjGYIhs (ORCPT + 99 others); Tue, 25 Jul 2023 04:37:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232803AbjGYIhV (ORCPT ); Tue, 25 Jul 2023 04:37:21 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4905F19BD; Tue, 25 Jul 2023 01:37:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690274236; x=1721810236; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Wrq3rwQEDKaPZJd20SlmwDK0bEVQC2vjYfUY/bdvPpc=; b=jSteRh7ByodX3SODR9qdFzwFcsK671wmBfdG/2urhbGqgP+h79Etsr5Z H5NPDxB7Hq1nukCKqQ5wb1Zys78WJA/DYo6/Ckl5pFP4n1uo9N6fi7kFI 3SBLqYgfJkh9lECA2tY/SYi9ghXO3TwJZacom1kVeXSht5O8TYKNfSD33 iDXvmWtmW7i8g0hZuRgGZwEeDpKMEmMx6RssVhMLUzEOoa7tgAfRZjd/C pgSyP4MFhEcOjOr3lrGY/aqE+ZdOgvSxrVAFaoIEJzHOYcY1QNAZM2TDJ tNkWVDUWCPwvpW/Q9SPxCTKHcIA+cqX3pBIJByXjPQKn63aLMjX91er+A w==; X-IronPort-AV: E=McAfee;i="6600,9927,10781"; a="371264533" X-IronPort-AV: E=Sophos;i="6.01,230,1684825200"; d="scan'208";a="371264533" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 01:37:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10781"; a="761130306" X-IronPort-AV: E=Sophos;i="6.01,230,1684825200"; d="scan'208";a="761130306" Received: from haibo-optiplex-7090.sh.intel.com ([10.239.159.132]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 01:37:08 -0700 From: Haibo Xu Cc: xiaobo55x@gmail.com, haibo1.xu@intel.com, ajones@ventanamicro.com, maz@kernel.org, oliver.upton@linux.dev, seanjc@google.com, Paolo Bonzini , Jonathan Corbet , Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Shuah Khan , James Morse , Suzuki K Poulose , Zenghui Yu , Ricardo Koller , Vishal Annapurve , Vitaly Kuznetsov , Vipin Sharma , David Matlack , Colton Lewis , kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Subject: [PATCH v6 05/13] KVM: arm64: selftests: Delete core_reg_fixup Date: Tue, 25 Jul 2023 16:41:31 +0800 Message-Id: <93de039c7772bc5eb0b44d24a596363e92fc1714.1690273969.git.haibo1.xu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772383550866353874 X-GMAIL-MSGID: 1772383550866353874 From: Andrew Jones core_reg_fixup() complicates sharing the get-reg-list test with other architectures. Rather than work at keeping it, with plenty of #ifdeffery, just delete it, as it's unlikely to test a kernel based on anything older than v5.2 with the get-reg-list test, which is a test meant to check for regressions in new kernels. (And, an older version of the test can still be used for older kernels if necessary.) Signed-off-by: Andrew Jones Signed-off-by: Haibo Xu --- .../selftests/kvm/aarch64/get-reg-list.c | 83 +++---------------- 1 file changed, 10 insertions(+), 73 deletions(-) diff --git a/tools/testing/selftests/kvm/aarch64/get-reg-list.c b/tools/testing/selftests/kvm/aarch64/get-reg-list.c index cb6b40e167d0..11630bbfb86b 100644 --- a/tools/testing/selftests/kvm/aarch64/get-reg-list.c +++ b/tools/testing/selftests/kvm/aarch64/get-reg-list.c @@ -17,12 +17,10 @@ * by running the test with the --list command line argument. * * Note, the blessed list should be created from the oldest possible - * kernel. We can't go older than v4.15, though, because that's the first - * release to expose the ID system registers in KVM_GET_REG_LIST, see - * commit 93390c0a1b20 ("arm64: KVM: Hide unsupported AArch64 CPU features - * from guests"). Also, one must use the --core-reg-fixup command line - * option when running on an older kernel that doesn't include df205b5c6328 - * ("KVM: arm64: Filter out invalid core register IDs in KVM_GET_REG_LIST") + * kernel. We can't go older than v5.2, though, because that's the first + * release which includes df205b5c6328 ("KVM: arm64: Filter out invalid + * core register IDs in KVM_GET_REG_LIST"). Without that commit the core + * registers won't match expectations. */ #include #include @@ -317,63 +315,6 @@ static void print_reg(const char *prefix, __u64 id) } } -/* - * Older kernels listed each 32-bit word of CORE registers separately. - * For 64 and 128-bit registers we need to ignore the extra words. We - * also need to fixup the sizes, because the older kernels stated all - * registers were 64-bit, even when they weren't. - */ -static void core_reg_fixup(void) -{ - struct kvm_reg_list *tmp; - __u64 id, core_off; - int i; - - tmp = calloc(1, sizeof(*tmp) + reg_list->n * sizeof(__u64)); - - for (i = 0; i < reg_list->n; ++i) { - id = reg_list->reg[i]; - - if ((id & KVM_REG_ARM_COPROC_MASK) != KVM_REG_ARM_CORE) { - tmp->reg[tmp->n++] = id; - continue; - } - - core_off = id & ~REG_MASK; - - switch (core_off) { - case 0x52: case 0xd2: case 0xd6: - /* - * These offsets are pointing at padding. - * We need to ignore them too. - */ - continue; - case KVM_REG_ARM_CORE_REG(fp_regs.vregs[0]) ... - KVM_REG_ARM_CORE_REG(fp_regs.vregs[31]): - if (core_off & 3) - continue; - id &= ~KVM_REG_SIZE_MASK; - id |= KVM_REG_SIZE_U128; - tmp->reg[tmp->n++] = id; - continue; - case KVM_REG_ARM_CORE_REG(fp_regs.fpsr): - case KVM_REG_ARM_CORE_REG(fp_regs.fpcr): - id &= ~KVM_REG_SIZE_MASK; - id |= KVM_REG_SIZE_U32; - tmp->reg[tmp->n++] = id; - continue; - default: - if (core_off & 1) - continue; - tmp->reg[tmp->n++] = id; - break; - } - } - - free(reg_list); - reg_list = tmp; -} - static void prepare_vcpu_init(struct vcpu_reg_list *c, struct kvm_vcpu_init *init) { struct vcpu_reg_sublist *s; @@ -412,7 +353,6 @@ static void check_supported(struct vcpu_reg_list *c) static bool print_list; static bool print_filtered; -static bool fixup_core_regs; static void run_test(struct vcpu_reg_list *c) { @@ -433,9 +373,6 @@ static void run_test(struct vcpu_reg_list *c) reg_list = vcpu_get_reg_list(vcpu); - if (fixup_core_regs) - core_reg_fixup(); - if (print_list || print_filtered) { putchar('\n'); for_each_reg(i) { @@ -563,7 +500,7 @@ static void help(void) printf( "\n" - "usage: get-reg-list [--config=] [--list] [--list-filtered] [--core-reg-fixup]\n\n" + "usage: get-reg-list [--config=] [--list] [--list-filtered]\n\n" " --config= Used to select a specific vcpu configuration for the test/listing\n" " '' may be\n"); @@ -577,7 +514,6 @@ static void help(void) "\n" " --list Print the register list rather than test it (requires --config)\n" " --list-filtered Print registers that would normally be filtered out (requires --config)\n" - " --core-reg-fixup Needed when running on old kernels with broken core reg listings\n" "\n" ); } @@ -609,9 +545,7 @@ int main(int ac, char **av) pid_t pid; for (i = 1; i < ac; ++i) { - if (strcmp(av[i], "--core-reg-fixup") == 0) - fixup_core_regs = true; - else if (strncmp(av[i], "--config", 8) == 0) + if (strncmp(av[i], "--config", 8) == 0) sel = parse_config(av[i]); else if (strcmp(av[i], "--list") == 0) print_list = true; @@ -654,8 +588,11 @@ int main(int ac, char **av) } /* - * The current blessed list was primed with the output of kernel version + * The original blessed list was primed with the output of kernel version * v4.15 with --core-reg-fixup and then later updated with new registers. + * (The --core-reg-fixup option and it's fixup function have been removed + * from the test, as it's unlikely to use this type of test on a kernel + * older than v5.2.) * * The blessed list is up to date with kernel version v6.4 (or so we hope) */