From patchwork Thu Feb 18 00:22:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 12092711 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43474C433DB for ; Thu, 18 Feb 2021 00:23:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E97D564DEC for ; Thu, 18 Feb 2021 00:23:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230031AbhBRAXB (ORCPT ); Wed, 17 Feb 2021 19:23:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230018AbhBRAXA (ORCPT ); Wed, 17 Feb 2021 19:23:00 -0500 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 C5117C0613D6 for ; Wed, 17 Feb 2021 16:22:19 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id j4so569624ybt.23 for ; Wed, 17 Feb 2021 16:22:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=PRyE4DuvxmKcKdm5ROiIEhCflgy/4d0H0JxsOnzUrZk=; b=aKznqUyu3qCbvyr9Jjmwnij/oFYrNnrZjcqBVtget+UuMDTnH52TPhLLszKagVon1w b3U7RMelO28y5X0QEUmYnqlzNl2E7/YUmBeXNWu3WMnGcK13dAmc3afYWDILLPsJYU84 LTqW3EkOV6LN/SmX/2PTxoW36BTCbsqBsEdN0kIJgRiY6LNxWIrWKXwgjDe7aa3117ET ROmR2upAvSlV6RG2iDjKjLzNv06m3LwHUxk7bYKYKBOmndIO1jOGcdTrezclQsllcUEU rHIfy6mZij/Di8nqw9KpsrhMUXvJtFv6Z82/rnErz5c0WUKjVUO6lRHPeI2SdLb6ESkw j9AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=PRyE4DuvxmKcKdm5ROiIEhCflgy/4d0H0JxsOnzUrZk=; b=RdjndschXnOF3xw44Q54TTh7NbFwD5CMLVR5sKXy0gyxpIM1JHmOMtptg8M4OtCj/d qe6916ZoPwQ8sWPhA92zhWOc7znMZ16wJRtJATv9YAxSyff572QAI3x6VZ5k9jnUBW3a iNYy6asi8cAN33+hYZSJdKMeZ1Xg7pYoNB88uElDo0KEF2wAeIlyB+6gD8laOeyzGlmv o9mQrfLSQQC3w39Bo0OHtEOAFA1xvVuwZ2WIrOwd33k4iakT2imeVfonhRNgYg19QWVx vWWwbzCApv+P7lwQmE4G/n5RbCqNbICXBP6pn/FmeeyenM2au8KRTpL1uVjHxrQGWx0D Tetg== X-Gm-Message-State: AOAM530OotMmCBc3WdOiC1aOd1cUzarSjkPHmRMSY2TTs176f5DmX5Dl gyfKgc/9GuyZXlwu9hpl+YwdxNJDZaM= X-Google-Smtp-Source: ABdhPJyflWiTey/5gO0p/MU+xC5QuBxKNa5CJ3MQS718L2AxRFywQOTJgp42z3w4+6dHbgJgaGoN612yVRw= Sender: "seanjc via sendgmr" X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:dc76:757f:9e9e:647c]) (user=seanjc job=sendgmr) by 2002:a25:6e02:: with SMTP id j2mr2847972ybc.247.1613607739007; Wed, 17 Feb 2021 16:22:19 -0800 (PST) Reply-To: Sean Christopherson Date: Wed, 17 Feb 2021 16:22:07 -0800 In-Reply-To: <20210218002212.2904647-1-seanjc@google.com> Message-Id: <20210218002212.2904647-2-seanjc@google.com> Mime-Version: 1.0 References: <20210218002212.2904647-1-seanjc@google.com> X-Mailer: git-send-email 2.30.0.478.g8a0d178c01-goog Subject: [kvm-unit-tests PATCH 1/6] x86: nVMX: Verify unrestricted guest is supported in segment tests From: Sean Christopherson To: Paolo Bonzini Cc: kvm@vger.kernel.org, Krish Sadhukhan , Sean Christopherson Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Enhance enable_unrestricted_guest() to allow configuring a fully valid EPT tree, and use the updated helper to verify unrestricted guest can be enabled before testing SS segment properties that are specific to unrestricted guest. Fixes: 7820ac5 ("nVMX: Test Selector and Base Address fields of Guest Segment Registers on vmentry of nested guests") Cc: Krish Sadhukhan Signed-off-by: Sean Christopherson --- x86/vmx_tests.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index da17b51..cf42619 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -1101,14 +1101,17 @@ static void setup_dummy_ept(void) report_abort("EPT setup unexpectedly failed"); } -static int enable_unrestricted_guest(void) +static int enable_unrestricted_guest(bool need_valid_ept) { if (!(ctrl_cpu_rev[0].clr & CPU_SECONDARY) || !(ctrl_cpu_rev[1].clr & CPU_URG) || !(ctrl_cpu_rev[1].clr & CPU_EPT)) return 1; - setup_dummy_ept(); + if (need_valid_ept) + setup_ept(false); + else + setup_dummy_ept(); vmcs_write(CPU_EXEC_CTRL0, vmcs_read(CPU_EXEC_CTRL0) | CPU_SECONDARY); vmcs_write(CPU_EXEC_CTRL1, vmcs_read(CPU_EXEC_CTRL1) | CPU_URG); @@ -4347,7 +4350,7 @@ static void test_invalid_event_injection(void) test_vmx_valid_controls(); report_prefix_pop(); - if (enable_unrestricted_guest()) + if (enable_unrestricted_guest(false)) goto skip_unrestricted_guest; ent_intr_info = ent_intr_info_base | INTR_INFO_DELIVER_CODE_MASK | @@ -8059,12 +8062,13 @@ static void test_guest_segment_sel_fields(void) ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3))); TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS", ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3))); + vmcs_write(CPU_EXEC_CTRL0, cpu_ctrl0_saved); + vmcs_write(CPU_EXEC_CTRL1, cpu_ctrl1_saved); + + /* Need a valid EPTP as the passing case fully enters the guest. */ + if (enable_unrestricted_guest(true)) + goto skip_ss_tests; - /* Turn on "unrestricted guest" vm-execution control */ - vmcs_write(CPU_EXEC_CTRL0, cpu_ctrl0_saved | CPU_SECONDARY); - vmcs_write(CPU_EXEC_CTRL1, cpu_ctrl1_saved | CPU_URG); - /* EPT and EPTP must be setup when "unrestricted guest" is on */ - setup_ept(false); TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS", ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3))); TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS", @@ -8078,6 +8082,7 @@ static void test_guest_segment_sel_fields(void) ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3))); TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS", ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3))); +skip_ss_tests: vmcs_write(GUEST_AR_SS, ar_saved); vmcs_write(GUEST_SEL_SS, sel_saved); From patchwork Thu Feb 18 00:22:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 12092719 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65E53C433E6 for ; Thu, 18 Feb 2021 00:23:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 154A164E79 for ; Thu, 18 Feb 2021 00:23:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230053AbhBRAXD (ORCPT ); Wed, 17 Feb 2021 19:23:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230018AbhBRAXC (ORCPT ); Wed, 17 Feb 2021 19:23:02 -0500 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 1214DC061786 for ; Wed, 17 Feb 2021 16:22:22 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id u3so607891ybj.13 for ; Wed, 17 Feb 2021 16:22:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=iBNwhQlaM8S1KFWuWRJxuU1NbrN0MOkrUcLNLYh5sLs=; b=sg02MMxXzTGpq1vDgtcRNnNJD1FYuOEBxMfPHbJ/nVr0nyTNMTIRP4/4k/cSf9ZV5L WC+2IJV1Yd2B8HkDe7aQ8m1kLYomfpxtihPgttraQCbiMduP2wizuVpcj3pzuusKkbg/ gNk66gqSVB60s22GIUkiH7IxeQuBoEku+uMugw8vNfLegF0sEK4G41tvkRwEX1b66YDW 9re777VdX/TGeLlAOqxGjFl47RTeDjIaDdwzvCvnX9HqYlvlUu7NQofHXETuM507KVgK Oawsq5wnEytGSTxnSWXYz9JJXlyIWO2ioFW6mjJmI/bqKDXmzilxel7qTX6A1uTzFiFP O2Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=iBNwhQlaM8S1KFWuWRJxuU1NbrN0MOkrUcLNLYh5sLs=; b=QYjLWrfFvrZmvvc/ByCLfe3Hyt40FoW7Tx9NUJFyKq8Fm0xkv9FvR1do2VFZ7OY5UW fRyO1OfsmiCsfGM55e7/xigTbTxkDlLiTrn8A2m9PxKLYHCaMABPRaxfGfkPvtokrkNx vY9ULWe4PG2KHaq8QB4es1FnW+bHoyyZlMI0HQYyMaAphSowDlVaMUUcrP14k+47e0TD RBL9eatYsBRwDbN+OBnPutffP2zlsm+YjmnK9yiroaeSGUQpGbSzk47rP7bXLmza2aHX NTnY4DwHrHQ1gulgYZJ6HNoCSetrovXG9kIDRD1G0E/UJL8tIFXYEvnHCLvzNpgUVl4P DXkQ== X-Gm-Message-State: AOAM530Z5jkATWCF9E3yp2WOzOjImwiolqBOmdgCMIiR9+74UTKrCZm+ b+Pax86ob5pxz2+tidNkyMtl0q/2lzU= X-Google-Smtp-Source: ABdhPJwQ50u1/ZJSKarV2fbiML4Mc4Of1uyD5gfwZZitjMpCWhMBDMY5SsRbdueg6zt93JRj4k0TzI3deoQ= Sender: "seanjc via sendgmr" X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:dc76:757f:9e9e:647c]) (user=seanjc job=sendgmr) by 2002:a05:6902:6b2:: with SMTP id j18mr2767325ybt.383.1613607741367; Wed, 17 Feb 2021 16:22:21 -0800 (PST) Reply-To: Sean Christopherson Date: Wed, 17 Feb 2021 16:22:08 -0800 In-Reply-To: <20210218002212.2904647-1-seanjc@google.com> Message-Id: <20210218002212.2904647-3-seanjc@google.com> Mime-Version: 1.0 References: <20210218002212.2904647-1-seanjc@google.com> X-Mailer: git-send-email 2.30.0.478.g8a0d178c01-goog Subject: [kvm-unit-tests PATCH 2/6] x86: nVMX: Skip unrestricted guest (URG) test if URG isn't supported From: Sean Christopherson To: Paolo Bonzini Cc: kvm@vger.kernel.org, Krish Sadhukhan , Sean Christopherson Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Use the enable_unrestricted_guest() helper to enable URG and bail if it URG isn't supported. EPT is also required for URG, but EPT can be enabled independent of URG, and some hardware support EPT but not URG, e.g. NHM. Fixes: f441716 ("nVMX: Test vmentry of unrestricted (PG=0/PE=1) nested guest") Cc: Krish Sadhukhan Signed-off-by: Sean Christopherson --- x86/vmx_tests.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index cf42619..35463b6 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -8266,12 +8266,14 @@ static void unsetup_unrestricted_guest(void) */ static void vmentry_unrestricted_guest_test(void) { + if (enable_unrestricted_guest(true)) { + report_skip("Unrestricted guest not supported"); + return; + } + test_set_guest(unrestricted_guest_main); setup_unrestricted_guest(); - if (setup_ept(false)) - test_skip("EPT not supported"); - vmcs_write(CPU_EXEC_CTRL1, vmcs_read(CPU_EXEC_CTRL1) | CPU_URG); - test_guest_state("Unrestricted guest test", false, CPU_URG, "CPU_URG"); + test_guest_state("Unrestricted guest test", false, CPU_URG, "CPU_URG"); /* * Let the guest finish execution as a regular guest From patchwork Thu Feb 18 00:22:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 12092715 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86855C43381 for ; Thu, 18 Feb 2021 00:23:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 346E564EAE for ; Thu, 18 Feb 2021 00:23:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230064AbhBRAXF (ORCPT ); Wed, 17 Feb 2021 19:23:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230018AbhBRAXE (ORCPT ); Wed, 17 Feb 2021 19:23:04 -0500 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 6F28BC061788 for ; Wed, 17 Feb 2021 16:22:24 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id 6so630694ybq.7 for ; Wed, 17 Feb 2021 16:22:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=rxD7Cfx1GqsmSmL2P7darQKc+AFaLsyrpkiIH6lHspA=; b=LQNnOingSAg+AL3Sigaum//AnfCSGXUZGSCViO/WKWbJaEQn1/FXZOJYAqX8K0PAIa XqnluSAId3sOouUwP/Kc/Zve4M7SZaVkLH5TCyni4pK9FGGKx9Lj8D/IiPZEf9ryiNWA Qdb7K0LEFBm4j9C6L1zBtyBwxpWqSEz0QbQqvdccmxE6y5J/kNs3rvLl4B65/jMzprkY VzGTzIDV9iSJySz34f4oWk+XDV0A88Mjy+9yeUDlNMSszosFaGkWZ6UFWc/gX+LX7F8N OBs4uANZHqMp5p6I5OA1LKQymV+BECdyC4zqkm26OfT5XrJaD04WVsKtCjmywkYjvyrr o5aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=rxD7Cfx1GqsmSmL2P7darQKc+AFaLsyrpkiIH6lHspA=; b=XqMpJs/0IopmNo4H/fHMcCld6P25dIb2/CU4WS7rq61XAZbh3Q1OgDQ1Yz35rjnPCy jzg6KWo3VvBlhj5cX26rwhSzVx2YHQRgbiz941tk6MeCPzK9PFeOT5tKJk0WEuPR9QIt 5s0tgVTHbd9ipZkR1A7OJgPMuKD6Q8RE8S1LIqQ+HSocKAsG61Dad/nuvMS8F0bCdIg7 pitITh8HNfu4mxUdUm06AuiklTyp2/08n5Fn8nGRn55IA2VGuQpsaX/OXKEZ85QfNfXY yKfXS7NbqeZt2pb9K+0IllPc/B4PHBpuahfiwEE27UYZ84rq73zZEDv5lmC4lkP4LFRI Ky6g== X-Gm-Message-State: AOAM531+dWZ4kATHwTp4Ob/xZfGY2kGyF3RcKEx+WIUh2wZ6y0hB47lR Dm1FZlq+aRh5uIWFzuBDYAFYvpcBthA= X-Google-Smtp-Source: ABdhPJzb7URA3rw3seV6AMppbxWPBjCEcaCUGtBdb1JkdC5tXnIBWrqtEy/1i2a9S2ora8/iDrCPZ4v/LvE= Sender: "seanjc via sendgmr" X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:dc76:757f:9e9e:647c]) (user=seanjc job=sendgmr) by 2002:a25:abce:: with SMTP id v72mr3310906ybi.152.1613607743713; Wed, 17 Feb 2021 16:22:23 -0800 (PST) Reply-To: Sean Christopherson Date: Wed, 17 Feb 2021 16:22:09 -0800 In-Reply-To: <20210218002212.2904647-1-seanjc@google.com> Message-Id: <20210218002212.2904647-4-seanjc@google.com> Mime-Version: 1.0 References: <20210218002212.2904647-1-seanjc@google.com> X-Mailer: git-send-email 2.30.0.478.g8a0d178c01-goog Subject: [kvm-unit-tests PATCH 3/6] x86: nVMX: Improve report messages for segment selector tests From: Sean Christopherson To: Paolo Bonzini Cc: kvm@vger.kernel.org, Krish Sadhukhan , Sean Christopherson Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Tweak the segment selector tests to clarify if they are testing a valid versus invalid condition, display the actual condition, and stringify the name of the field instead of copy-pasting the field name into a string. Opportunistically wrap the complex macro in a do-while. Signed-off-by: Sean Christopherson --- x86/vmx_tests.c | 57 ++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index 35463b6..4ea2624 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -7985,10 +7985,19 @@ static void test_load_guest_bndcfgs(void) #define GUEST_SEG_UNUSABLE_MASK (1u << 16) #define GUEST_SEG_SEL_TI_MASK (1u << 2) -#define TEST_SEGMENT_SEL(xfail, sel, sel_name, val) \ + + +#define TEST_SEGMENT_SEL(test, xfail, sel, val) \ +do { \ vmcs_write(sel, val); \ - test_guest_state("Test Guest Segment Selector", xfail, val, \ - sel_name); + test_guest_state(test " segment", xfail, val, xstr(sel)); \ +} while (0) + +#define TEST_INVALID_SEG_SEL(sel, val) \ + TEST_SEGMENT_SEL("Invalid: " xstr(val), true, sel, val); + +#define TEST_VALID_SEG_SEL(sel, val) \ + TEST_SEGMENT_SEL("Valid: " xstr(val), false, sel, val); /* * The following checks are done on the Selector field of the Guest Segment @@ -8013,8 +8022,7 @@ static void test_guest_segment_sel_fields(void) * Test for GUEST_SEL_TR */ sel_saved = vmcs_read(GUEST_SEL_TR); - TEST_SEGMENT_SEL(true, GUEST_SEL_TR, "GUEST_SEL_TR", - sel_saved | GUEST_SEG_SEL_TI_MASK); + TEST_INVALID_SEG_SEL(GUEST_SEL_TR, sel_saved | GUEST_SEG_SEL_TI_MASK); vmcs_write(GUEST_SEL_TR, sel_saved); /* @@ -8024,17 +8032,13 @@ static void test_guest_segment_sel_fields(void) ar_saved = vmcs_read(GUEST_AR_LDTR); /* LDTR is set unusable */ vmcs_write(GUEST_AR_LDTR, ar_saved | GUEST_SEG_UNUSABLE_MASK); - TEST_SEGMENT_SEL(false, GUEST_SEL_LDTR, "GUEST_SEL_LDTR", - sel_saved | GUEST_SEG_SEL_TI_MASK); - TEST_SEGMENT_SEL(false, GUEST_SEL_LDTR, "GUEST_SEL_LDTR", - sel_saved & ~GUEST_SEG_SEL_TI_MASK); + TEST_VALID_SEG_SEL(GUEST_SEL_LDTR, sel_saved | GUEST_SEG_SEL_TI_MASK); + TEST_VALID_SEG_SEL(GUEST_SEL_LDTR, sel_saved & ~GUEST_SEG_SEL_TI_MASK); /* LDTR is set usable */ vmcs_write(GUEST_AR_LDTR, ar_saved & ~GUEST_SEG_UNUSABLE_MASK); - TEST_SEGMENT_SEL(true, GUEST_SEL_LDTR, "GUEST_SEL_LDTR", - sel_saved | GUEST_SEG_SEL_TI_MASK); + TEST_INVALID_SEG_SEL(GUEST_SEL_LDTR, sel_saved | GUEST_SEG_SEL_TI_MASK); - TEST_SEGMENT_SEL(false, GUEST_SEL_LDTR, "GUEST_SEL_LDTR", - sel_saved & ~GUEST_SEG_SEL_TI_MASK); + TEST_VALID_SEG_SEL(GUEST_SEL_LDTR, sel_saved & ~GUEST_SEG_SEL_TI_MASK); vmcs_write(GUEST_AR_LDTR, ar_saved); vmcs_write(GUEST_SEL_LDTR, sel_saved); @@ -8049,39 +8053,30 @@ static void test_guest_segment_sel_fields(void) vmcs_write(CPU_EXEC_CTRL1, cpu_ctrl1_saved & ~CPU_URG); cs_rpl_bits = vmcs_read(GUEST_SEL_CS) & 0x3; sel_saved = vmcs_read(GUEST_SEL_SS); - TEST_SEGMENT_SEL(true, GUEST_SEL_SS, "GUEST_SEL_SS", - ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3))); - TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS", - ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3))); + TEST_INVALID_SEG_SEL(GUEST_SEL_SS, ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3))); + TEST_VALID_SEG_SEL(GUEST_SEL_SS, ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3))); /* Make SS usable if it's unusable or vice-versa */ if (ar_saved & GUEST_SEG_UNUSABLE_MASK) vmcs_write(GUEST_AR_SS, ar_saved & ~GUEST_SEG_UNUSABLE_MASK); else vmcs_write(GUEST_AR_SS, ar_saved | GUEST_SEG_UNUSABLE_MASK); - TEST_SEGMENT_SEL(true, GUEST_SEL_SS, "GUEST_SEL_SS", - ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3))); - TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS", - ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3))); - vmcs_write(CPU_EXEC_CTRL0, cpu_ctrl0_saved); - vmcs_write(CPU_EXEC_CTRL1, cpu_ctrl1_saved); + TEST_INVALID_SEG_SEL(GUEST_SEL_SS, ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3))); + TEST_VALID_SEG_SEL(GUEST_SEL_SS, ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3))); /* Need a valid EPTP as the passing case fully enters the guest. */ if (enable_unrestricted_guest(true)) goto skip_ss_tests; - TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS", - ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3))); - TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS", - ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3))); + TEST_VALID_SEG_SEL(GUEST_SEL_SS, ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3))); + TEST_VALID_SEG_SEL(GUEST_SEL_SS, ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3))); + /* Make SS usable if it's unusable or vice-versa */ if (vmcs_read(GUEST_AR_SS) & GUEST_SEG_UNUSABLE_MASK) vmcs_write(GUEST_AR_SS, ar_saved & ~GUEST_SEG_UNUSABLE_MASK); else vmcs_write(GUEST_AR_SS, ar_saved | GUEST_SEG_UNUSABLE_MASK); - TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS", - ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3))); - TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS", - ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3))); + TEST_VALID_SEG_SEL(GUEST_SEL_SS, ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3))); + TEST_VALID_SEG_SEL(GUEST_SEL_SS, ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3))); skip_ss_tests: vmcs_write(GUEST_AR_SS, ar_saved); From patchwork Thu Feb 18 00:22:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 12092713 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6B49C433E9 for ; Thu, 18 Feb 2021 00:23:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B49264EAF for ; Thu, 18 Feb 2021 00:23:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230017AbhBRAXL (ORCPT ); Wed, 17 Feb 2021 19:23:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229745AbhBRAXK (ORCPT ); Wed, 17 Feb 2021 19:23:10 -0500 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 BE60DC06178A for ; Wed, 17 Feb 2021 16:22:26 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id v6so623024ybk.9 for ; Wed, 17 Feb 2021 16:22:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=N5u+tYaA6jheO+s3TAYApGNDG7kt8AjvjeXnlM3gIWM=; b=qtyX3O2CMgZmUaDOiNhk1mGOb/MPylrnIyF/boq3B2Pd16GZPOhcUM8QnfEnCLdkLH M0kAuC1OWSHLd9chonD8xejblgRPETL2oHTXAwZKi9GqJOIZLndSPyQIS7gaJHdifTqc NLtt5sQa+OiRGVuDq01d3k68F9TtTL7uisHmM5m30CniTjp2/MGKqTLfXq4PdYAwrLLT hVdondAKS0BZYnSKjX7imuqYdPqtWSSRG7Jz4qy1bRagGBQuicU7h64+Vb8VaVh48Jlo v5vguKwyGCGa1LP6StdnxEG5bMVGG7nNwanQMtMAX3NqqXvGNsY6UaXivutc9BHceEGN v3Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=N5u+tYaA6jheO+s3TAYApGNDG7kt8AjvjeXnlM3gIWM=; b=H9Q0fsf12S+1zvcBk1Y9vD4/6IzshXayGWSd4CIKZTNOUpt6x4daKj0J2r7C4PASqz pLQXWndX32cKHyoLUrpvz//hAa4HKCjz45bdVfIEF+u1z7VBmOMQzrkbx3X/tk1HfKLV 1o9WqTMrf2YEjCqBfvDuBaQZhtbR5tcls0Eot//A7WKdR1bLIbfAfSJL5+1BQ0J1GDaT ygLToM1YHdeAU6EiJcvh+oeqNYyVijuF1OZdXxMXJrbAByvVkKDRu0nYUcQVqAz1UDjq Vy4VBqS+JkChdQ97DQfLvyLbvF2+htpyhFkDvWCgnbaSQ28ZczRVBciBynAuPg6/jKSF wU/Q== X-Gm-Message-State: AOAM533P4yyPzRTrF/PCbuMMhHZ7Q9784UduQgjmq532j+tDDQpkldRk FRzMS7mBxdGwsPA74pJxhE2cM6s66qM= X-Google-Smtp-Source: ABdhPJz/aoTxw95aEuVUHG09L+tENFh2lidZIeh4/kTigJZPsy/SgMR8unS42hU020VTwA92qZ4J4pMxKKY= Sender: "seanjc via sendgmr" X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:dc76:757f:9e9e:647c]) (user=seanjc job=sendgmr) by 2002:a25:1fc5:: with SMTP id f188mr2904496ybf.389.1613607746050; Wed, 17 Feb 2021 16:22:26 -0800 (PST) Reply-To: Sean Christopherson Date: Wed, 17 Feb 2021 16:22:10 -0800 In-Reply-To: <20210218002212.2904647-1-seanjc@google.com> Message-Id: <20210218002212.2904647-5-seanjc@google.com> Mime-Version: 1.0 References: <20210218002212.2904647-1-seanjc@google.com> X-Mailer: git-send-email 2.30.0.478.g8a0d178c01-goog Subject: [kvm-unit-tests PATCH 4/6] x86: nVMX: Improve report messages for segment base tests From: Sean Christopherson To: Paolo Bonzini Cc: kvm@vger.kernel.org, Krish Sadhukhan , Sean Christopherson Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Tweak the segment base tests to state exactly what's being tested, note whether or not the segment is usable, and stringify the name of the field instead of copy-pasting the field name into a string. Opportunistically wrap the complex macros in do-while. Signed-off-by: Sean Christopherson --- x86/vmx_tests.c | 67 +++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index 4ea2624..94ab499 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -8085,22 +8085,26 @@ skip_ss_tests: vmcs_write(CPU_EXEC_CTRL1, cpu_ctrl1_saved); } -#define TEST_SEGMENT_BASE_ADDR_UPPER_BITS(xfail, seg_base, seg_base_name)\ - addr_saved = vmcs_read(seg_base); \ - for (i = 32; i < 63; i = i + 4) { \ - addr = addr_saved | 1ull << i; \ - vmcs_write(seg_base, addr); \ - test_guest_state(seg_base_name, xfail, addr, \ - seg_base_name); \ - } \ - vmcs_write(seg_base, addr_saved); +#define TEST_SEGMENT_BASE_ADDR_UPPER_BITS(xfail, seg_base) \ +do { \ + addr_saved = vmcs_read(seg_base); \ + for (i = 32; i < 63; i = i + 4) { \ + addr = addr_saved | 1ull << i; \ + vmcs_write(seg_base, addr); \ + test_guest_state("seg.BASE[63:32] != 0, usable = " xstr(xfail), \ + xfail, addr, xstr(seg_base)); \ + } \ + vmcs_write(seg_base, addr_saved); \ +} while (0) -#define TEST_SEGMENT_BASE_ADDR_CANONICAL(xfail, seg_base, seg_base_name)\ - addr_saved = vmcs_read(seg_base); \ - vmcs_write(seg_base, NONCANONICAL); \ - test_guest_state(seg_base_name, xfail, NONCANONICAL, \ - seg_base_name); \ - vmcs_write(seg_base, addr_saved); +#define TEST_SEGMENT_BASE_ADDR_CANONICAL(xfail, seg_base) \ +do { \ + addr_saved = vmcs_read(seg_base); \ + vmcs_write(seg_base, NONCANONICAL); \ + test_guest_state("seg.BASE non-canonical, usable = " xstr(xfail), \ + xfail, NONCANONICAL, xstr(seg_base)); \ + vmcs_write(seg_base, addr_saved); \ +} while (0) /* * The following checks are done on the Base Address field of the Guest @@ -8123,57 +8127,48 @@ static void test_guest_segment_base_addr_fields(void) /* * The address of TR, FS, GS and LDTR must be canonical. */ - TEST_SEGMENT_BASE_ADDR_CANONICAL(true, GUEST_BASE_TR, "GUEST_BASE_TR"); - TEST_SEGMENT_BASE_ADDR_CANONICAL(true, GUEST_BASE_FS, "GUEST_BASE_FS"); - TEST_SEGMENT_BASE_ADDR_CANONICAL(true, GUEST_BASE_GS, "GUEST_BASE_GS"); + TEST_SEGMENT_BASE_ADDR_CANONICAL(true, GUEST_BASE_TR); + TEST_SEGMENT_BASE_ADDR_CANONICAL(true, GUEST_BASE_FS); + TEST_SEGMENT_BASE_ADDR_CANONICAL(true, GUEST_BASE_GS); ar_saved = vmcs_read(GUEST_AR_LDTR); /* Make LDTR unusable */ vmcs_write(GUEST_AR_LDTR, ar_saved | GUEST_SEG_UNUSABLE_MASK); - TEST_SEGMENT_BASE_ADDR_CANONICAL(false, GUEST_BASE_LDTR, - "GUEST_BASE_LDTR"); + TEST_SEGMENT_BASE_ADDR_CANONICAL(false, GUEST_BASE_LDTR); /* Make LDTR usable */ vmcs_write(GUEST_AR_LDTR, ar_saved & ~GUEST_SEG_UNUSABLE_MASK); - TEST_SEGMENT_BASE_ADDR_CANONICAL(true, GUEST_BASE_LDTR, - "GUEST_BASE_LDTR"); + TEST_SEGMENT_BASE_ADDR_CANONICAL(true, GUEST_BASE_LDTR); vmcs_write(GUEST_AR_LDTR, ar_saved); /* * Bits 63:32 in CS, SS, DS and ES base address must be zero */ - TEST_SEGMENT_BASE_ADDR_UPPER_BITS(true, GUEST_BASE_CS, - "GUEST_BASE_CS"); + TEST_SEGMENT_BASE_ADDR_UPPER_BITS(true, GUEST_BASE_CS); ar_saved = vmcs_read(GUEST_AR_SS); /* Make SS unusable */ vmcs_write(GUEST_AR_SS, ar_saved | GUEST_SEG_UNUSABLE_MASK); - TEST_SEGMENT_BASE_ADDR_UPPER_BITS(false, GUEST_BASE_SS, - "GUEST_BASE_SS"); + TEST_SEGMENT_BASE_ADDR_UPPER_BITS(false, GUEST_BASE_SS); /* Make SS usable */ vmcs_write(GUEST_AR_SS, ar_saved & ~GUEST_SEG_UNUSABLE_MASK); - TEST_SEGMENT_BASE_ADDR_UPPER_BITS(true, GUEST_BASE_SS, - "GUEST_BASE_SS"); + TEST_SEGMENT_BASE_ADDR_UPPER_BITS(true, GUEST_BASE_SS); vmcs_write(GUEST_AR_SS, ar_saved); ar_saved = vmcs_read(GUEST_AR_DS); /* Make DS unusable */ vmcs_write(GUEST_AR_DS, ar_saved | GUEST_SEG_UNUSABLE_MASK); - TEST_SEGMENT_BASE_ADDR_UPPER_BITS(false, GUEST_BASE_DS, - "GUEST_BASE_DS"); + TEST_SEGMENT_BASE_ADDR_UPPER_BITS(false, GUEST_BASE_DS); /* Make DS usable */ vmcs_write(GUEST_AR_DS, ar_saved & ~GUEST_SEG_UNUSABLE_MASK); - TEST_SEGMENT_BASE_ADDR_UPPER_BITS(true, GUEST_BASE_DS, - "GUEST_BASE_DS"); + TEST_SEGMENT_BASE_ADDR_UPPER_BITS(true, GUEST_BASE_DS); vmcs_write(GUEST_AR_DS, ar_saved); ar_saved = vmcs_read(GUEST_AR_ES); /* Make ES unusable */ vmcs_write(GUEST_AR_ES, ar_saved | GUEST_SEG_UNUSABLE_MASK); - TEST_SEGMENT_BASE_ADDR_UPPER_BITS(false, GUEST_BASE_ES, - "GUEST_BASE_ES"); + TEST_SEGMENT_BASE_ADDR_UPPER_BITS(false, GUEST_BASE_ES); /* Make ES usable */ vmcs_write(GUEST_AR_ES, ar_saved & ~GUEST_SEG_UNUSABLE_MASK); - TEST_SEGMENT_BASE_ADDR_UPPER_BITS(true, GUEST_BASE_ES, - "GUEST_BASE_ES"); + TEST_SEGMENT_BASE_ADDR_UPPER_BITS(true, GUEST_BASE_ES); vmcs_write(GUEST_AR_ES, ar_saved); } From patchwork Thu Feb 18 00:22:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 12092717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C867BC4332B for ; Thu, 18 Feb 2021 00:23:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8392164E42 for ; Thu, 18 Feb 2021 00:23:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230071AbhBRAXM (ORCPT ); Wed, 17 Feb 2021 19:23:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229919AbhBRAXK (ORCPT ); Wed, 17 Feb 2021 19:23:10 -0500 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F04E6C06178B for ; Wed, 17 Feb 2021 16:22:28 -0800 (PST) Received: by mail-qk1-x749.google.com with SMTP id x21so183322qkm.19 for ; Wed, 17 Feb 2021 16:22:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=B5/JuJRrp4tSajA98STkVloyawJT2dkhjvJPRU2rLz4=; b=Pxbyk9AivqqatV9+7lD7nBGmULHWAXryKVycSN4YNyFk+Prlc3uYkF0/S62lmq+Ho6 pVVoz+DDKbn2IoQ4fnuH/kkf8RvPQepWzVOlvuTOPuAQVn6jtb1iDLuBUae6IR6cFKBD f7+QGHXHmQqec7Bn2MXy7d6klV/ybmA3t7mbl0Ut1WR1QNhD+WJWy51DP/x9R9KkVaav IDD1UDMYFTV77gtvpS7atAx2rbGoKJkJjxrh7MukqBJxtWjImBNaNOlVehJ7w2Yqb7J7 130GePYF2UleSyNJL6O8z8cOhGee5NUK5E9m8aR0gU/86rySc970DYLgWPczSTpmxOwM ca8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=B5/JuJRrp4tSajA98STkVloyawJT2dkhjvJPRU2rLz4=; b=lfAhVxtyVKF8A0zEe/DyQcmuz4tVgEfCmn+jJSCyQRszJol1rCVk1SffhN3HkH1WFZ QhMOXUTA81BfD8qopMiWtXiydmgc4lLJ9lTTdrmAQXtu1QZhvCboRkgLr/94UXF7lSBe kVmvzUOflDIyPTBwL6/e+GfvOwuCpyP3G80d11kSH4TIo+5H0KLbLAvwQO4MPk1qarLt 1mxOsrfYHTp/YFmRKz00OdHZnO6ECSBaILx/iICu9UKTanlnfrHRORzk0jq4kE5RU4Vl vtYhSryTstfBIX7F2UpptHaePW+dhvNcZNDVWmiSVPoVPa9jqorSDj32+W76EHcmihEa ezdw== X-Gm-Message-State: AOAM533aAFTt0pmOTFxN+i42wRAjWW6dRaZXOCx5QdsAxNKY7SYMjeyn vXm/2xSoygneatXmR3K8nRsT+vuv5mE= X-Google-Smtp-Source: ABdhPJyNrZbxoI3xWUsnoAsyuGYyp0dOsQOnKcKSnbFW79GKS9497OaOqtfbsd7Nxe4jRuOSDHoYpjxqjJU= Sender: "seanjc via sendgmr" X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:dc76:757f:9e9e:647c]) (user=seanjc job=sendgmr) by 2002:ad4:54ad:: with SMTP id r13mr1772282qvy.48.1613607748144; Wed, 17 Feb 2021 16:22:28 -0800 (PST) Reply-To: Sean Christopherson Date: Wed, 17 Feb 2021 16:22:11 -0800 In-Reply-To: <20210218002212.2904647-1-seanjc@google.com> Message-Id: <20210218002212.2904647-6-seanjc@google.com> Mime-Version: 1.0 References: <20210218002212.2904647-1-seanjc@google.com> X-Mailer: git-send-email 2.30.0.478.g8a0d178c01-goog Subject: [kvm-unit-tests PATCH 5/6] x86: nVMX: Use more descriptive name for GDT/IDT limit tests From: Sean Christopherson To: Paolo Bonzini Cc: kvm@vger.kernel.org, Krish Sadhukhan , Sean Christopherson Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Explicitly state that the invalid limit tests are testing a limit greater than 0xffff. Simply stating the field name is not helpful since it's already printed on failure. Signed-off-by: Sean Christopherson --- x86/vmx_tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index 94ab499..1097a53 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -8205,7 +8205,7 @@ static void vmx_guest_state_area_test(void) for (i = 16; i <= 31; i++) { u32 tmp = guest_desc_limit_saved | (1ull << i); vmcs_write(GUEST_LIMIT_GDTR, tmp); - test_guest_state("GUEST_LIMIT_GDTR", true, tmp, "GUEST_LIMIT_GDTR"); + test_guest_state("GDT.limit > 0xffff", true, tmp, "GUEST_LIMIT_GDTR"); } vmcs_write(GUEST_LIMIT_GDTR, guest_desc_limit_saved); @@ -8213,7 +8213,7 @@ static void vmx_guest_state_area_test(void) for (i = 16; i <= 31; i++) { u32 tmp = guest_desc_limit_saved | (1ull << i); vmcs_write(GUEST_LIMIT_IDTR, tmp); - test_guest_state("GUEST_LIMIT_IDTR", true, tmp, "GUEST_LIMIT_IDTR"); + test_guest_state("IDT.limit > 0xffff", true, tmp, "GUEST_LIMIT_IDTR"); } vmcs_write(GUEST_LIMIT_IDTR, guest_desc_limit_saved); From patchwork Thu Feb 18 00:22:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 12092721 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 253DAC433E0 for ; Thu, 18 Feb 2021 00:23:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CAC7F64E4B for ; Thu, 18 Feb 2021 00:23:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230087AbhBRAXi (ORCPT ); Wed, 17 Feb 2021 19:23:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230073AbhBRAXh (ORCPT ); Wed, 17 Feb 2021 19:23:37 -0500 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EE30C061574 for ; Wed, 17 Feb 2021 16:22:31 -0800 (PST) Received: by mail-qv1-xf49.google.com with SMTP id j6so140144qvo.11 for ; Wed, 17 Feb 2021 16:22:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=ZhQicEFmrpuvHlcNr0+AZHJmdWlkJ87sdk7eG/kCGi0=; b=OvFcaTvTg7Mho7C/LKicQIKI2e36a2VoL8uFa+yIHFuxyV+RvzeVPJdShrXdRPG09o Z0sXWmbbZzafeGea1oAiOZmAPDrhzsZRbR0xRLNvLybeb44eb9tGU+2/MrDoixIa86j5 daOAVLi3zdUpjWDTkN7Rs2g6iBdBRRyG4tV+MCOYFbJ37iAhcduaL4Mq47tTEdFB6dob 6qkNmY4BgzYGO/E5NnReCJfHqORvje94lD/kUGhWLYi0eX9CeGVCFdw3EZwrL44Je/oN 6gE6Z+Mg8Q1+CnLf5J/WLR0xDa8oLCGAV+3PfGFRn440FAQBpNjZ8tDqJ/BEYovJMdDG R5GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=ZhQicEFmrpuvHlcNr0+AZHJmdWlkJ87sdk7eG/kCGi0=; b=T/LVQvDMsCxgEJFvLCUe6AxExknOwRafG5n1JfzK0liEh+kPyIjK4QLLzoQH3xX1lB N/C7hOkBOKmMjJ20vu1oeO4ColKytMzBJ2THtpq30y6iHyfF8mW9xbDGEvmbBW/YnnsR xktLm6vCOxBkaZ6NqJs638+XdA4QbgFMGnpX8gr+4PYEIDDgY5QMJhz1ESfjF5txzoss AX66ml3n+vcK2VZWcwFKSlAUdNbWYmPWyeRFmxZNDglFz2wgV54IC4HBzr7CGzo2/LX4 U2FkpSqwMhXOpPN5qb9bnRH7H6jXK97e5BNQWmiM015BFhTZ0bF6toh0ZrlgvenZn804 KN0Q== X-Gm-Message-State: AOAM5333zpQSRTqjo97twHdXtEZIKIqHfDSSDY5Ga2ZGlHRV4dZ5Iskg tp7/qdi1c5aKMeSyslxpvXARdhGhWUs= X-Google-Smtp-Source: ABdhPJzfHGLj42+lIXpEGOYvtsbIeKTTQlFHTvb6BgWIgAuGy+Pej59hPRPjv03/mMCuoJlvNcwGOK2NnGE= Sender: "seanjc via sendgmr" X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:dc76:757f:9e9e:647c]) (user=seanjc job=sendgmr) by 2002:a0c:c687:: with SMTP id d7mr1854255qvj.17.1613607750422; Wed, 17 Feb 2021 16:22:30 -0800 (PST) Reply-To: Sean Christopherson Date: Wed, 17 Feb 2021 16:22:12 -0800 In-Reply-To: <20210218002212.2904647-1-seanjc@google.com> Message-Id: <20210218002212.2904647-7-seanjc@google.com> Mime-Version: 1.0 References: <20210218002212.2904647-1-seanjc@google.com> X-Mailer: git-send-email 2.30.0.478.g8a0d178c01-goog Subject: [kvm-unit-tests PATCH 6/6] x86: nVMX: Add an equals sign to show value assoc. in test_guest_state() From: Sean Christopherson To: Paolo Bonzini Cc: kvm@vger.kernel.org, Krish Sadhukhan , Sean Christopherson Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Insert "=" between the field name and its value when reporting a failure in test_guest_state() to make it obvious that the number is the value of the field. Signed-off-by: Sean Christopherson --- x86/vmx_tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index 1097a53..f9883f0 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -5556,7 +5556,7 @@ static void test_guest_state(const char *test, bool xfail, u64 field, ((xfail && result.exit_reason.basic == VMX_FAIL_STATE) || (!xfail && result.exit_reason.basic == VMX_VMCALL)) && (!xfail || vmcs_read(EXI_QUALIFICATION) == ENTRY_FAIL_DEFAULT), - "%s, %s %lx", test, field_name, field); + "%s, %s = %lx", test, field_name, field); if (!result.exit_reason.failed_vmentry) skip_exit_insn();