From patchwork Fri Sep 24 00:51:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12513815 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 D7EFDC433F5 for ; Fri, 24 Sep 2021 00:52:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B784260F13 for ; Fri, 24 Sep 2021 00:52:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243675AbhIXAxc (ORCPT ); Thu, 23 Sep 2021 20:53:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232143AbhIXAxb (ORCPT ); Thu, 23 Sep 2021 20:53:31 -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 012A8C061574 for ; Thu, 23 Sep 2021 17:51:59 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id m16-20020a25d410000000b005ab243aaaf4so1353025ybf.20 for ; Thu, 23 Sep 2021 17:51:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=5zJLsaCyRuyfAgJHK0NO/2qjz/xHTuNLfww2cDY3wZc=; b=AWPrN28YZxlrkUw55d/+wP8wHc1VqClUupCBy+9GiM/x+Nmu3d463KD3yZPA+AGKS4 KEos1TKD35+2xki4IPbD1gq20FK9NlyQl4F6OalOvpgmFucaVqqnEnO/Nc6+hSPFDmvO NGOn4pS9ecQpFOkPjHghU6LubyWQw9R21yZ7UvjqExL9vUupsKW+I7ebgGsgrC1ygG0A ZKBC5kSdiIhDyoyGY4nsXtF/Je4YlBbDwM6goAKKk3M02svEmXo1cyAVsMif84BriWvh p1SNaSB8qmz4z4YTdxUFt0oSK2gllk1TN5Ckcgv0YUJoLRNpozl7/OHgh3rOd8+Uu1j/ /gIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=5zJLsaCyRuyfAgJHK0NO/2qjz/xHTuNLfww2cDY3wZc=; b=UtX2cC61UbHCQao9BAjHEutNc3u6n2NwjGYWChZ9YkqQZlefIJUj6wggZ+zifDWXZw 5tKzF29r7rIe3GuzB/DKx/MJgBgs9HOkZyKiDnRQtgYrmJjehVzhI0v6JYofd+dm8KP9 mjEzGtH7wqY1dTOU48JbcdCQ46KC1QFIpT/AY0tgE/AzsOk8El1/7K+nwGgKZg7oJ8b4 YEeB9jncs93SW4pg0SJciRjYVrwhgzJgh3CPhjkdhTKTKG3Nl3e6G8i6kbdJTlc8LkGy 5q86Prqf4KHM6rzwvYsjX8KLmN8KXj/2Qs6S89psvQ4ncGDWDkDnabOWCh6RGEm7bJdq zSvA== X-Gm-Message-State: AOAM53269/LwZEQdtHUZBJYTtqT2oOIAkoLK2SD52jLDypbds9Elusu/ NMd1+opL8YbMmLg7z84JI2KL06q/45WKOP1dJWE+OAopZi8JOFPq5j+oUzrcYToVaD+HC+O+y8S o2pU+2POPfA4GC/T8nazlp8smlBMo4pTuiTXQoyVivSmyJJUTyXIKIDjpUg== X-Google-Smtp-Source: ABdhPJy81zEtbxA/0CCCI3JjgDOIIr45GMlPsH+JyDe1Jf+y5wmjpREvcKfTdvmwuyuZWx8UJvVAP8a0AF8= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a25:2e0f:: with SMTP id u15mr9845297ybu.133.1632444718119; Thu, 23 Sep 2021 17:51:58 -0700 (PDT) Date: Fri, 24 Sep 2021 00:51:47 +0000 Message-Id: <20210924005147.1122357-1-oupton@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.33.0.685.g46640cef36-goog Subject: [PATCH] selftests: KVM: Explicitly use movq to read xmm registers From: Oliver Upton To: kvm@vger.kernel.org Cc: Paolo Bonzini , Jim Mattson , Ricardo Koller , Sean Christopherson , Oliver Upton Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Compiling the KVM selftests with clang emits the following warning: >> include/x86_64/processor.h:297:25: error: variable 'xmm0' is uninitialized when used here [-Werror,-Wuninitialized] >> return (unsigned long)xmm0; where xmm0 is accessed via an uninitialized register variable. Indeed, this is a misuse of register variables, which really should only be used for specifying register constraints on variables passed to inline assembly. Rather than attempting to read xmm registers via register variables, just explicitly perform the movq from the desired xmm register. Fixes: 783e9e51266e ("kvm: selftests: add API testing infrastructure") Signed-off-by: Oliver Upton Reviewed-by: Ricardo Koller --- .../selftests/kvm/include/x86_64/processor.h | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h index 242ae8e09a65..eba8bd08293e 100644 --- a/tools/testing/selftests/kvm/include/x86_64/processor.h +++ b/tools/testing/selftests/kvm/include/x86_64/processor.h @@ -312,37 +312,37 @@ static inline void set_xmm(int n, unsigned long val) } } -typedef unsigned long v1di __attribute__ ((vector_size (8))); +#define GET_XMM(__xmm) \ +({ \ + unsigned long __val; \ + asm volatile("movq %%"#__xmm", %0" : "=r"(__val) : : #__xmm); \ + __val; \ +}) + static inline unsigned long get_xmm(int n) { assert(n >= 0 && n <= 7); - register v1di xmm0 __asm__("%xmm0"); - register v1di xmm1 __asm__("%xmm1"); - register v1di xmm2 __asm__("%xmm2"); - register v1di xmm3 __asm__("%xmm3"); - register v1di xmm4 __asm__("%xmm4"); - register v1di xmm5 __asm__("%xmm5"); - register v1di xmm6 __asm__("%xmm6"); - register v1di xmm7 __asm__("%xmm7"); switch (n) { case 0: - return (unsigned long)xmm0; + return GET_XMM(xmm0); case 1: - return (unsigned long)xmm1; + return GET_XMM(xmm1); case 2: - return (unsigned long)xmm2; + return GET_XMM(xmm2); case 3: - return (unsigned long)xmm3; + return GET_XMM(xmm3); case 4: - return (unsigned long)xmm4; + return GET_XMM(xmm4); case 5: - return (unsigned long)xmm5; + return GET_XMM(xmm5); case 6: - return (unsigned long)xmm6; + return GET_XMM(xmm6); case 7: - return (unsigned long)xmm7; + return GET_XMM(xmm7); } + + /* never reached */ return 0; }