From patchwork Fri Jul 22 23:48:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 12926991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A167C433EF for ; Fri, 22 Jul 2022 23:48:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236315AbiGVXsr (ORCPT ); Fri, 22 Jul 2022 19:48:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235452AbiGVXsp (ORCPT ); Fri, 22 Jul 2022 19:48:45 -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 8201EBF9BD for ; Fri, 22 Jul 2022 16:48:44 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 83-20020a250156000000b006707fbc22ddso4714856ybb.3 for ; Fri, 22 Jul 2022 16:48:44 -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=KFQW7jsAcLHmWp9w2LJQVvYaLlYILuaNUn+12sIyDcY=; b=qxbrGOijKZeV2cD7ZxgNjzGsfWLCuscD/Si2sRkuqHSu8wUOQXPslVMbJSSYHi5WV+ u/HvgFWLP/siEPKRUx4ziTzEQfjV2d5L3UuvlCJV9K3ptVIlSVxIQKSE3MG02rfw/iDw lhwjyYlOwSTv/J29vvRVTu8HAfmQIrV3muEmsRAX1KDRoAZD4nHKZvPQXhV23lK9xjsh E9/rln3BX1SRs/9gCiQFyyUAydR3G2hJB4rVIv1vSAblexVGKvYmaXjRbdTez46Aufsr YgUpMKo7UeZR9+ProUmVORWAcH/QmnfYzfumj9HF8aC4d/xGrCmSybQJL/2mqD+JpIWf jdSw== 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=KFQW7jsAcLHmWp9w2LJQVvYaLlYILuaNUn+12sIyDcY=; b=JnkCW7OaUqVJG/QL6KCc6FWpk3fw7sZo9z0/W6nxh7ntalVyuCF2DesZClC0mAaJ5v zLV/Qclp633/MJv6D4kXOivGdD/7v7U4faeIiObzod9T2EHTdugkzwXIC2cZqQqV8mkZ jmO3WEBiLI/XSc/0QXfbvST220SV0OY783l/XMKie3jl1xldTwyjc7zggEyZeYmXwved //OmjMkH/tHjf92ybLgTgHQQPNd/nIuXah7QR8i0j2VmBRDJDAk+HsoYUcsKHcQBR4V8 7FnBezVH0VKN+zIJsnCi73LKvyWbWGwaAyohYfjj/O3eTg/ICL6AKMImHWqm2LElectE UKtw== X-Gm-Message-State: AJIora+xrEKerwDZn886Q9O6L47i6GMDTtzh8cEo6+7ndso+rxkc/RzQ LuklvNG/r7YAvCH0osWjFSdBN94GGUeVdQ== X-Google-Smtp-Source: AGRyM1sOKspIXC3FlbYTAoXrIrzhWcsWZPMFx9n/05iN/AmSnKvxUUNxuiPxUVme/T+yNRebujFPkHOoZl+wog== X-Received: from dmatlack-n2d-128.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1309]) (user=dmatlack job=sendgmr) by 2002:a25:d606:0:b0:66e:b73d:5de3 with SMTP id n6-20020a25d606000000b0066eb73d5de3mr1845516ybg.360.1658533723862; Fri, 22 Jul 2022 16:48:43 -0700 (PDT) Date: Fri, 22 Jul 2022 23:48:37 +0000 In-Reply-To: <20220722234838.2160385-1-dmatlack@google.com> Message-Id: <20220722234838.2160385-2-dmatlack@google.com> Mime-Version: 1.0 References: <20220722234838.2160385-1-dmatlack@google.com> X-Mailer: git-send-email 2.37.1.359.gd136c6c3e2-goog Subject: [PATCH 1/2] KVM: selftests: Fix KVM_EXCEPTION_MAGIC build with Clang From: David Matlack To: Paolo Bonzini Cc: Nathan Chancellor , Nick Desaulniers , Tom Rix , Sean Christopherson , Peter Xu , David Matlack , Jim Mattson , Oliver Upton , "open list:CLANG/LLVM BUILD SUPPORT" , kvm@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Change KVM_EXCEPTION_MAGIC to use the all-caps "ULL", rather than lower case. This fixes a build failure with Clang: In file included from x86_64/hyperv_features.c:13: include/x86_64/processor.h:825:9: error: unexpected token in argument list return kvm_asm_safe("wrmsr", "a"(val & -1u), "d"(val >> 32), "c"(msr)); ^ include/x86_64/processor.h:802:15: note: expanded from macro 'kvm_asm_safe' asm volatile(KVM_ASM_SAFE(insn) \ ^ include/x86_64/processor.h:785:2: note: expanded from macro 'KVM_ASM_SAFE' "mov $" __stringify(KVM_EXCEPTION_MAGIC) ", %%r9\n\t" \ ^ :1:18: note: instantiated into assembly here mov $0xabacadabaull, %r9 ^ Fixes: 3b23054cd3f5 ("KVM: selftests: Add x86-64 support for exception fixup") Signed-off-by: David Matlack Reviewed-by: Sean Christopherson --- tools/testing/selftests/kvm/include/x86_64/processor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h index 45edf45821d0..51c6661aca77 100644 --- a/tools/testing/selftests/kvm/include/x86_64/processor.h +++ b/tools/testing/selftests/kvm/include/x86_64/processor.h @@ -754,7 +754,7 @@ void vm_install_exception_handler(struct kvm_vm *vm, int vector, void (*handler)(struct ex_regs *)); /* If a toddler were to say "abracadabra". */ -#define KVM_EXCEPTION_MAGIC 0xabacadabaull +#define KVM_EXCEPTION_MAGIC 0xabacadabaULL /* * KVM selftest exception fixup uses registers to coordinate with the exception From patchwork Fri Jul 22 23:48:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 12926992 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95C39C43334 for ; Fri, 22 Jul 2022 23:48:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236399AbiGVXst (ORCPT ); Fri, 22 Jul 2022 19:48:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234919AbiGVXsr (ORCPT ); Fri, 22 Jul 2022 19:48:47 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6F65C06C2 for ; Fri, 22 Jul 2022 16:48:46 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-31e65a848daso50605917b3.20 for ; Fri, 22 Jul 2022 16:48:46 -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=C5vxcKBsXfUKk2MUSnDuijEsY5Uu1XCESOEGFEpHan4=; b=Utdu1V3aRcGKKdAJiX1P6WXcvxoJLpXF8LbdwZgQ2R2R8j/6WsY8HUYm06OrvZY4B9 VZDgDdFPliKb2A21kfpagaDCr3hSzuk07GJTzX4xKoYTukGX7X6x+v/OKdMt08DlJQuL cip9S4pmjPz13jQlWcDoQqd98cR7AgfDgYdBZO0qwLNfICob/mXUBOmSEaeKyxCwPhg3 Xh7PlWjmdmj8mxZ2E/AZ7Ud1E6YVP1qJ16h2kryDbkLHW+FlihzkrITlgMCXm7fJxHp+ pKUyuBIrrv/yMsooOhKXxACpWSPyQ7idgj+jQ0J1T2hWTjCh750l11CsZ1SGFvf+QVPO JZCA== 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=C5vxcKBsXfUKk2MUSnDuijEsY5Uu1XCESOEGFEpHan4=; b=wdvQv5ZX50AmAp2NDr/+7ZV4p0q/3njEEtbNeLeNRffme/fJsnrViYMUD1sZHXji2s giOVQ1H/WBQGfGMte5XPXjdggovIomYbDUkyWCpplDv7Mor7kpO96IrHn3QapvQbGoJZ Ngfp2LtRv4VDE/yFhYmjNYpMi+PadIfTHSJqPwjpavIDIxIApin8yvXNkiREyd3LQSKD GdF7GXpceS1h96UGHqr0KlBC9A+xno6jWsijDPqEubNiArUSfjsqIWiSWuyaa1uX6VXp pbumMrF9oPh6L3ocQx6MF2KF3MgfjU3nW9mVuph38x7PJ4rgAcgwfwgOUiQpyLwpKlg4 OPvw== X-Gm-Message-State: AJIora8lVz70jvVve996l07BAcxzN2gCFWfo3QI/10sZSdi75iAed0cH zvGSixwS/udCxNtDK2/ScaNeX/wlXvC7kw== X-Google-Smtp-Source: AGRyM1tn9WYAdHKqq6lfJAZm8nBg32Zv2QGSkMx1BhgjaHTdJKmr0cWym95nsT9ukBiTU4ZQC0T077veefdMvQ== X-Received: from dmatlack-n2d-128.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1309]) (user=dmatlack job=sendgmr) by 2002:a0d:c603:0:b0:31e:7d54:17fd with SMTP id i3-20020a0dc603000000b0031e7d5417fdmr1922347ywd.421.1658533726164; Fri, 22 Jul 2022 16:48:46 -0700 (PDT) Date: Fri, 22 Jul 2022 23:48:38 +0000 In-Reply-To: <20220722234838.2160385-1-dmatlack@google.com> Message-Id: <20220722234838.2160385-3-dmatlack@google.com> Mime-Version: 1.0 References: <20220722234838.2160385-1-dmatlack@google.com> X-Mailer: git-send-email 2.37.1.359.gd136c6c3e2-goog Subject: [PATCH 2/2] KVM: selftests: Fix ambiguous mov in KVM_ASM_SAFE() From: David Matlack To: Paolo Bonzini Cc: Nathan Chancellor , Nick Desaulniers , Tom Rix , Sean Christopherson , Peter Xu , David Matlack , Jim Mattson , Oliver Upton , "open list:CLANG/LLVM BUILD SUPPORT" , kvm@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Change the mov in KVM_ASM_SAFE() that zeroes @vector to a movb to make it unambiguous. This fixes a build failure with Clang since, unlike the GNU assembler, the LLVM integrated assembler rejects ambiguous X86 instructions that don't have suffixes: In file included from x86_64/hyperv_features.c:13: include/x86_64/processor.h:825:9: error: ambiguous instructions require an explicit suffix (could be 'movb', 'movw', 'movl', or 'movq') return kvm_asm_safe("wrmsr", "a"(val & -1u), "d"(val >> 32), "c"(msr)); ^ include/x86_64/processor.h:802:15: note: expanded from macro 'kvm_asm_safe' asm volatile(KVM_ASM_SAFE(insn) \ ^ include/x86_64/processor.h:788:16: note: expanded from macro 'KVM_ASM_SAFE' "1: " insn "\n\t" \ ^ :5:2: note: instantiated into assembly here mov $0, 15(%rsp) ^ It seems like this change could introduce undesirable behavior in the future, e.g. if someone used a type larger than a u8 for @vector, since KVM_ASM_SAFE() will only zero the bottom byte. I tried changing the type of @vector to an int to see what would happen. GCC failed to compile due to a size mismatch between `movb` and `%eax`. Clang succeeded in compiling, but the generated code looked correct, so perhaps it will not be an issue. That being said it seems like there could be a better solution to this issue that does not assume @vector is a u8. Fixes: 3b23054cd3f5 ("KVM: selftests: Add x86-64 support for exception fixup") Signed-off-by: David Matlack Reviewed-by: Sean Christopherson --- tools/testing/selftests/kvm/include/x86_64/processor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h index 51c6661aca77..0cbc71b7af50 100644 --- a/tools/testing/selftests/kvm/include/x86_64/processor.h +++ b/tools/testing/selftests/kvm/include/x86_64/processor.h @@ -786,7 +786,7 @@ void vm_install_exception_handler(struct kvm_vm *vm, int vector, "lea 1f(%%rip), %%r10\n\t" \ "lea 2f(%%rip), %%r11\n\t" \ "1: " insn "\n\t" \ - "mov $0, %[vector]\n\t" \ + "movb $0, %[vector]\n\t" \ "jmp 3f\n\t" \ "2:\n\t" \ "mov %%r9b, %[vector]\n\t" \