From patchwork Wed Sep 13 12:08:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 722123 Delivered-To: patch@linaro.org Received: by 2002:a5d:4387:0:b0:31d:da82:a3b4 with SMTP id i7csp257110wrq; Wed, 13 Sep 2023 05:09:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHTyd+GP2g43fwtB4Lav69JTjETyJ7N4c5O7NF5+j30yxcfuQUYzX/am12wE3tqYqLXEvik X-Received: by 2002:a05:620a:4001:b0:76d:a784:9685 with SMTP id h1-20020a05620a400100b0076da7849685mr2612579qko.28.1694606993768; Wed, 13 Sep 2023 05:09:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694606993; cv=none; d=google.com; s=arc-20160816; b=nSU3OdtmpDa/MVTadesGdczIdLsIcnYqtx7cqr0B3vlTxSXMf247BaRRxBkfEbdhHH mIu3zw0u3NUnSC6FukyyYdcPNBLh6rW8bJ5JSf7CBd70Q9cjVRcIZs9dxYzsCWulU37m oryWx/1NVPaiIvJWJ86d4z/8DCMy7+sHFhdRHgJrC1p668fE7NhQvx/NhlSsbV4QC5Oc TfGdF2uyj4UGJFlbG1czH80rjowG0Gjo9nbp69F+eobjvx772dfAOHqGL+lpDi4KO/rX 2tK2qpk0xfYyC+6mhCfdFS9q4M2COsiRY3j7IEEYcRhGDmkEL3UTo0XVAdIbqYrVxggS t+Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=78V6AUCfEa5S4vTUncfdyPTfOlLBu9pITh1WEI4+Qq0=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=DjRBv6N5w0xgkGPpkxRfdbNDVznMOGZedh0Ud9Vy621JDY3jYpDqJ71nuG/l448afH FOMz5ENh7zJoU0tOaWAGX05kMtnxtvMdkNthkFI+94esZC6Nb4NpqEAPdZqfGai2Tez2 pNzUc7h9AgXnyjohkpSPhUq0nkWY88iyrEyfKJvOdUD9xi63mO/Dt8QArZuqT07FldA0 slmwMn/9hngcHhhchF7WwG/LECudjN+H78Px735ug2R8Cr8P39LJayHHUPnhaX+8OcI7 RIRDpWiupOMGXjrcZ1wYFv50DnFXBBH0J7IwXvrGtj7QYplz7HGdffkI6UyynhriBEVb f+yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IadwVw2J; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ri1-20020a05620a8f8100b00767f226bc82si7073324qkn.315.2023.09.13.05.09.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Sep 2023 05:09:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IadwVw2J; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgOfo-0000j8-Te; Wed, 13 Sep 2023 08:08:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgOfb-0000bR-SY for qemu-devel@nongnu.org; Wed, 13 Sep 2023 08:08:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgOfV-0002XH-NJ for qemu-devel@nongnu.org; Wed, 13 Sep 2023 08:08:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694606908; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=78V6AUCfEa5S4vTUncfdyPTfOlLBu9pITh1WEI4+Qq0=; b=IadwVw2J9bKH8Z3QuzUrRj2bKnU3ffoxn2vFiiWnBeKjAt/amRe11QuqfIbxUisMWhCf3D qsApySWe7oN0FBaKDwd1jM4czghYaTbgtKVgRVNoYHWSnXc0N6TXPAFj0RshCOGAmx3l/R UshpH+t3lWWQr2gEMb3FwmDyBgoX8Xc= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-47-dW6J3fjzPdy16G1A0StOfg-1; Wed, 13 Sep 2023 08:08:26 -0400 X-MC-Unique: dW6J3fjzPdy16G1A0StOfg-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-401ea9bf934so52567315e9.2 for ; Wed, 13 Sep 2023 05:08:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694606905; x=1695211705; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=78V6AUCfEa5S4vTUncfdyPTfOlLBu9pITh1WEI4+Qq0=; b=LZwz5a4frrnmuXNbProy7NyKolXLI7FyWXDDpFWh19mCiFR4sn91I82QPhu1OqGEhZ gJX74VEMvDo8YY8rVGvcmCpcGRr6Za03wdo1GKVEB7TPFAjhBgBuGYDFPBlzkB0YTMA4 UIeDSetf2GtccTkkRx/SowrUhQJVcFeTMq8UTFhucUW0yEa0eZRdpmOsLPXYRMj4Zy5g yWfYOFYI9FQUhPrlgrON8cLi2YmxdJoLyvwV8R7SyBafZXy37RBbEtgwgglJzkOreAjK wK/ToGcGLs33VcalFs1H4mVkAbHvDcV8I+A3uw/UcdBTZI3XHUrCKFyw9Q+ZxKBmerL2 d16A== X-Gm-Message-State: AOJu0Yw2pS8PUCJGnNWkKKQOk6S4dC75ie+lCOhhTCO6+9xC2cXJ4TEc XvR7AZiZjbGWJHhetfBIB0CxymeevU2OkDd4T9j+XlCNXZp7U99x6tPtDNUM4BNy6NCdkq1KxGd dGLYftSB4YkalfVq3CMyqaTNt1R3dxxK+3E/c5x/K51BujlAcP2SCf9jea1aUzJhhQFP9Ru7hHF U= X-Received: by 2002:a05:600c:108b:b0:3fe:207c:1aea with SMTP id e11-20020a05600c108b00b003fe207c1aeamr1755401wmd.23.1694606905374; Wed, 13 Sep 2023 05:08:25 -0700 (PDT) X-Received: by 2002:a05:600c:108b:b0:3fe:207c:1aea with SMTP id e11-20020a05600c108b00b003fe207c1aeamr1755386wmd.23.1694606905019; Wed, 13 Sep 2023 05:08:25 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003fe2b081661sm1911669wmc.30.2023.09.13.05.08.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 05:08:23 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 2/4] target/i386: Check kvm_hyperv_expand_features() return value Date: Wed, 13 Sep 2023 14:08:18 +0200 Message-ID: <20230913120820.969262-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230913120820.969262-1-pbonzini@redhat.com> References: <20230913120820.969262-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé In case more code is added after the kvm_hyperv_expand_features() call, check its return value (since it can fail). Fixes: 071ce4b03b ("i386: expand Hyper-V features during CPU feature expansion time") Signed-off-by: Philippe Mathieu-Daudé Message-ID: <20230913093009.83520-2-philmd@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 24ee67b42d0..bd6a932d088 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7121,8 +7121,8 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **errp) env->cpuid_xlevel2 = env->cpuid_min_xlevel2; } - if (kvm_enabled()) { - kvm_hyperv_expand_features(cpu, errp); + if (kvm_enabled() && !kvm_hyperv_expand_features(cpu, errp)) { + return; } } From patchwork Wed Sep 13 12:08:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 722124 Delivered-To: patch@linaro.org Received: by 2002:a5d:4387:0:b0:31d:da82:a3b4 with SMTP id i7csp257228wrq; Wed, 13 Sep 2023 05:10:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE4CUQSY1/bsULmwmuyzKgubj9u0Y69Zlk1yTjA1jjBErX2twkCEFy8UqPJIExqdN3uQ2hq X-Received: by 2002:a0c:aa07:0:b0:649:384f:ed4 with SMTP id d7-20020a0caa07000000b00649384f0ed4mr2040508qvb.19.1694607006320; Wed, 13 Sep 2023 05:10:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694607006; cv=none; d=google.com; s=arc-20160816; b=v1+doLuV6W20aPvmHRbJ0b8LXQW+0nJyZtEl4U8lk05hsg8sTH8r0BxdA1jgq1RRkZ mXN/DRDrgyRYRg22sKI51jlqIqd9UjJwRNX8fPWG68u7J3sNefWS+b7buXovzEXzW5dS 13/4y8ExOE50F8hz3kqLnNVxDRFXxE5GjRTkV1IOL0HX0xcw2NA4yLke7v3pH0krRHiC cm7xV71MHtv+RRJcFRD6cu2JM2xp7LpaRij1Pw1ZGCICeX19LaEBn+C/tgvAtsRZMyuH fvp0/1mksZU13y8xBb6oHXn48/3X/j4HJQ50GCIsUVGrIW43tniATLraepm3x1WfckKH Twcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9C5AefYQjmcOrbVMvLJ5+TEGEUahAOHdAuWdhroUX3Q=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=Qne5ZhmMCujbP9o9DkfCnKwTpFRe3MiCbN7BSsa34K/dvP76mGrxbKt6mxcSYWgp22 V336qwk1faRnP/Wo0rkpGWxIgEK1jt3TLLqHM2uspnEdgypIUPydcKKAduUuR4CMt9Y+ vXApf/GNr3k6RCQTPbiG5e4pfBu7HH48RKAiqha2LoUqE09wz8ITK8aOIVn6bGe8ioDc 1mTsrA/4SaQr9JEBA3FGiRDEzxeMJzTwiaMsCFafi0oDkqQV6czbhIl9sQonc3kKUeW5 XgitoJ5s6FVapwnp7Aakaqb7r9JtnAzaEGMcz5QnCN+bJmfODtLseKawN3upaflU9TRZ 1VQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gVMTRgQF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f9-20020a0ccc89000000b0064f6e534e25si6955047qvl.586.2023.09.13.05.10.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Sep 2023 05:10:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gVMTRgQF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgOfr-0000mZ-8h; Wed, 13 Sep 2023 08:08:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgOfe-0000fE-KK for qemu-devel@nongnu.org; Wed, 13 Sep 2023 08:08:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgOfa-0002XV-5b for qemu-devel@nongnu.org; Wed, 13 Sep 2023 08:08:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694606910; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9C5AefYQjmcOrbVMvLJ5+TEGEUahAOHdAuWdhroUX3Q=; b=gVMTRgQFMK+ai8b2xQ3gxne2/3x8QOHPM3ZF2jCr/LEIKf6+urcsV5d9fT8Uw43lxhANCv f5rdbZlPVtAoxwh58gkbzPSsrs0rEQQtxdoxiUEm8IQgGGwD0aAooJi9BRj0aQVHGmH/Fr 0hDIYpL8kSxDWxjews8JObcvwiwp2Kk= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-148-hRgzP1OmNseWt4PREP5aqA-1; Wed, 13 Sep 2023 08:08:29 -0400 X-MC-Unique: hRgzP1OmNseWt4PREP5aqA-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-31f3233861aso4871509f8f.2 for ; Wed, 13 Sep 2023 05:08:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694606907; x=1695211707; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9C5AefYQjmcOrbVMvLJ5+TEGEUahAOHdAuWdhroUX3Q=; b=L1qhPiHcEjCf91Fc3hZ9mKN7HMxcLGxsdS15EwiGNvsBo0iWwFY9lnirahNnJQhJm2 zPQffnqqXgGxsao894KyyPxlA2SHt4yki1f5DERKS/wK42YaH+iUpvs7JswVxdMJCdPf EJdTDZwWGvqUUl7iuZl4L1u/RRECMZhI14eve9xwwWsY7L0Yv7Xf8oEvz59AmqqQSGAh 4rZ+rBFgcPcUFPSuz1SO/CyqD2QYA1rL5iorTZzquEqjFNSBEw6x7vu9RDiMGNWs8wHs eRaV98y4NonkhUTKfFOjmz5J3jgl82deyqVgL/5ACSdS5A1DI+w5rJVyw7vPQOKpk8II wB3Q== X-Gm-Message-State: AOJu0YzI4Zce5DBlviAKyljXF4MkNPPxuefoB91bKIXOJOrr9tasjaHw +kM1p4/H2PL3HFAKoErnwLmbZ5KTJwyUkV9p8v20aIjlMYu7k43hZFp//JphXawyLKOiVSqA9qb JJXgKkMAD7Vhx6UxMWFsAp2rjHnwz5zaBWIYUXlOTYBw9KTLpek5ArLpKQ8z+KNO4TmM+JXYcCi 4= X-Received: by 2002:a5d:6106:0:b0:319:731f:748c with SMTP id v6-20020a5d6106000000b00319731f748cmr1920814wrt.34.1694606907178; Wed, 13 Sep 2023 05:08:27 -0700 (PDT) X-Received: by 2002:a5d:6106:0:b0:319:731f:748c with SMTP id v6-20020a5d6106000000b00319731f748cmr1920790wrt.34.1694606906775; Wed, 13 Sep 2023 05:08:26 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id q13-20020a05600000cd00b0031ad2f9269dsm15341745wrx.40.2023.09.13.05.08.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 05:08:25 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 3/4] target/i386: Drop accel_uses_host_cpuid before x86_cpu_get_supported_cpuid Date: Wed, 13 Sep 2023 14:08:19 +0200 Message-ID: <20230913120820.969262-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230913120820.969262-1-pbonzini@redhat.com> References: <20230913120820.969262-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé x86_cpu_get_supported_cpuid() already checks for KVM/HVF accelerators, so it is not needed to manually check it via a call to accel_uses_host_cpuid() before calling it. Suggested-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daudé Message-ID: <20230913093009.83520-3-philmd@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index bd6a932d088..94b1ba0cf1a 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6207,7 +6207,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, break; case 0xA: /* Architectural Performance Monitoring Leaf */ - if (accel_uses_host_cpuid() && cpu->enable_pmu) { + if (cpu->enable_pmu) { x86_cpu_get_supported_cpuid(0xA, count, eax, ebx, ecx, edx); } else { *eax = 0; @@ -6247,8 +6247,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *ebx &= 0xffff; /* The count doesn't need to be reliable. */ break; case 0x1C: - if (accel_uses_host_cpuid() && cpu->enable_pmu && - (env->features[FEAT_7_0_EDX] & CPUID_7_0_EDX_ARCH_LBR)) { + if (cpu->enable_pmu && (env->features[FEAT_7_0_EDX] & CPUID_7_0_EDX_ARCH_LBR)) { x86_cpu_get_supported_cpuid(0x1C, 0, eax, ebx, ecx, edx); *edx = 0; } @@ -6322,9 +6321,8 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, } else { *ecx &= ~XSTATE_ARCH_LBR_MASK; } - } else if (count == 0xf && - accel_uses_host_cpuid() && cpu->enable_pmu && - (env->features[FEAT_7_0_EDX] & CPUID_7_0_EDX_ARCH_LBR)) { + } else if (count == 0xf && cpu->enable_pmu + && (env->features[FEAT_7_0_EDX] & CPUID_7_0_EDX_ARCH_LBR)) { x86_cpu_get_supported_cpuid(0xD, count, eax, ebx, ecx, edx); } else if (count < ARRAY_SIZE(x86_ext_save_areas)) { const ExtSaveArea *esa = &x86_ext_save_areas[count]; From patchwork Wed Sep 13 12:08:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 722125 Delivered-To: patch@linaro.org Received: by 2002:a5d:4387:0:b0:31d:da82:a3b4 with SMTP id i7csp257463wrq; Wed, 13 Sep 2023 05:10:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4kJjszFcwRy1WZiz3BaBfbuI6fMrDTNH7GGNoqAy2NLMELcTr2M2a/uInV6dCdTKNbD+R X-Received: by 2002:a05:620a:280a:b0:76c:ea6c:599b with SMTP id f10-20020a05620a280a00b0076cea6c599bmr2503959qkp.33.1694607032557; Wed, 13 Sep 2023 05:10:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694607032; cv=none; d=google.com; s=arc-20160816; b=yA9bGaHrn0xtXNlFcRJZkBHPLGf/SJibwWZAXdUd1sXlvOHdnCKb3bUh1yaJWTiDMc BmRszUBV3T96rTfTxNH+SNLVv43/PyvfC1x1ht7nbViiXiqwvvRbe5sdMRsVSCsa+IkV xZnC7tAlrO8BuE88xlK3rZCtyZOwRH22GQVjKqHl3Om9DbDhNZNvdmN2CmDTHthEzkFJ ulVoJJ9Trc5ZRfDGeMvffeMwfrrv/DrFAwR5MrHZS+iBA65GguHGGGp/NXosrHsChNnn F41lixl8bawTfPUEjdlB+U6mmSwceoNHlz5cp1nfHUP5JB04z0t+JwaBhr2/sHLqje9W 7iIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aN9k5zUDuNjjzyxNolQqBVnKvHeScWptj4QdERC1zd4=; fh=TyDAmFjUDBGwcjcjqxmHJjGox/FR40OWLwv/8egnbMY=; b=lJhwiEQrnS3FXuC5a1pZD0YGa09BhBclgLhQCUm1VUFWoVlSurEthdSJrBunckTS6O BPVwm0HzG+gG/lCRXD1vYp+hbnwo+Vn1qVy0xoM7A71FCGEDagVdg5BO4KlKj3n3BFQd 62HhMh0iDP4OMxc3yqPYo8fjE2kRfMvobZtE5iRYiROAGbtJal0/jBPu+u9IqUZvUX6g daYO4nglRzAtbUI10/QIvMk29c/cP9WXUqGbhOXLe8Mf5tarpFVaJyjpszDWnL/6RTGK pjthx7Fy9DZUUBx93RZUtUlcIKq356pd1z3Ld5WT2QbcacxOETQKxlKwuceCh4Js1BVa pYog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LYOMklFJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w10-20020a05620a424a00b007672916d246si7178997qko.606.2023.09.13.05.10.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Sep 2023 05:10:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LYOMklFJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgOfw-0000pN-6O; Wed, 13 Sep 2023 08:08:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgOfm-0000ir-MR for qemu-devel@nongnu.org; Wed, 13 Sep 2023 08:08:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgOfc-0002YN-48 for qemu-devel@nongnu.org; Wed, 13 Sep 2023 08:08:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694606912; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aN9k5zUDuNjjzyxNolQqBVnKvHeScWptj4QdERC1zd4=; b=LYOMklFJn89C7RRLyb+CnsvkcME+DGUcj9VIT2Eb2LOba1w87tn/NPeRNe1o9KOtDDuQFS mp/zXLzTZigG+VvM8cmjBjQ8jOp7+hoi8HAWidRhuZoq21VOH3wtK0GekF1k/Hxb/T1WNA qV0skoFZe2nT4CJCYTmcjp2Wjfj00cQ= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-449-9-h-v-a4M4WqzSn2IBzMhw-1; Wed, 13 Sep 2023 08:08:31 -0400 X-MC-Unique: 9-h-v-a4M4WqzSn2IBzMhw-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-31f3cfe7269so4422570f8f.2 for ; Wed, 13 Sep 2023 05:08:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694606909; x=1695211709; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aN9k5zUDuNjjzyxNolQqBVnKvHeScWptj4QdERC1zd4=; b=VkzmmQxElXypNnN52s+NdkxDPRvgtBzEm4ERg/sgTnhKRphJprdGt63aML2os+jrcR T+deKc1ZXih27/hCBWdCRgtvUmdHaDG8l5iJ/oYXWxurQXbAoLakx0FdBco6qaaZfTdE /2CrqLmRMK5AqguuWGGP/7pKDaWf/3C7PN2ZUBY4x2z/E4UydULUD4BSma6XR81i1XER Ac0S4jP6zTGPep6vOJ8ZDceuFhDNrrKUGNVDVwuv7viMIety0wEqIo/0q2hcZx3158r8 hoW1eTGTVy8UIiEORoeK2E85hw3csawPwAOnWWleEO/X4/BQ+h2wAIT+kYA4uY238vvQ y4UA== X-Gm-Message-State: AOJu0YweEQolzERpUlLm79mWtleAfprYy8Y1s0xR9cJsyIpRZbMj5r8x 4EFTFY2afU5iTFAwj9mRZuismS1BKyl+8U9aTNHq7i3vb46apw8dmM7IFwhXQHVJ8EOuJvv632K ot78BFwFQ5SlyDh1z7pkUtEwW6Nu0W02tMP3cqab89FW8G2nMtmHvjJWWJmNWfjEg7L2cFpLDpW Q= X-Received: by 2002:adf:f60d:0:b0:31c:4c68:e73a with SMTP id t13-20020adff60d000000b0031c4c68e73amr1791858wrp.66.1694606909087; Wed, 13 Sep 2023 05:08:29 -0700 (PDT) X-Received: by 2002:adf:f60d:0:b0:31c:4c68:e73a with SMTP id t13-20020adff60d000000b0031c4c68e73amr1791841wrp.66.1694606908666; Wed, 13 Sep 2023 05:08:28 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id j12-20020adfe50c000000b003176aa612b1sm15315147wrm.38.2023.09.13.05.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 05:08:27 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-stable@nongnu.org, Kevin Wolf Subject: [PULL 4/4] target/i386: Call accel-agnostic x86_cpu_get_supported_cpuid() Date: Wed, 13 Sep 2023 14:08:20 +0200 Message-ID: <20230913120820.969262-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230913120820.969262-1-pbonzini@redhat.com> References: <20230913120820.969262-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé x86_cpu_get_supported_cpuid() is generic and handles the different accelerators. Use it instead of kvm_arch_get_supported_cpuid(). That fixes a link failure introduced by commit 3adce820cf ("target/i386: Remove unused KVM stubs") when QEMU is configured as: $ ./configure --cc=clang \ --target-list=x86_64-linux-user,x86_64-softmmu \ --enable-debug We were getting: [71/71] Linking target qemu-x86_64 FAILED: qemu-x86_64 /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `cpu_x86_cpuid': cpu.c:(.text+0x1374): undefined reference to `kvm_arch_get_supported_cpuid' /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o: in function `x86_cpu_filter_features': cpu.c:(.text+0x81c2): undefined reference to `kvm_arch_get_supported_cpuid' /usr/bin/ld: cpu.c:(.text+0x81da): undefined reference to `kvm_arch_get_supported_cpuid' /usr/bin/ld: cpu.c:(.text+0x81f2): undefined reference to `kvm_arch_get_supported_cpuid' /usr/bin/ld: cpu.c:(.text+0x820a): undefined reference to `kvm_arch_get_supported_cpuid' /usr/bin/ld: libqemu-x86_64-linux-user.fa.p/target_i386_cpu.c.o:cpu.c:(.text+0x8225): more undefined references to `kvm_arch_get_supported_cpuid' follow clang: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed. For the record, this is because '--enable-debug' disables optimizations (CFLAGS=-O0). While at this (un)optimization level GCC eliminate the following dead code (CPP output of mentioned build): static void x86_cpu_get_supported_cpuid(uint32_t func, uint32_t index, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { if ((0)) { *eax = kvm_arch_get_supported_cpuid(kvm_state, func, index, R_EAX); *ebx = kvm_arch_get_supported_cpuid(kvm_state, func, index, R_EBX); *ecx = kvm_arch_get_supported_cpuid(kvm_state, func, index, R_ECX); *edx = kvm_arch_get_supported_cpuid(kvm_state, func, index, R_EDX); } else if (0) { *eax = 0; *ebx = 0; *ecx = 0; *edx = 0; } else { *eax = 0; *ebx = 0; *ecx = 0; *edx = 0; } Clang does not (see commit 2140cfa51d "i386: Fix build by providing stub kvm_arch_get_supported_cpuid()"). Cc: qemu-stable@nongnu.org Fixes: 3adce820cf ("target/i386: Remove unused KVM stubs") Reported-by: Kevin Wolf Suggested-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daudé Message-ID: <20230913093009.83520-4-philmd@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 94b1ba0cf1a..b2a20365e10 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6154,6 +6154,8 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, case 7: /* Structured Extended Feature Flags Enumeration Leaf */ if (count == 0) { + uint32_t eax_0_unused, ebx_0, ecx_0, edx_0_unused; + /* Maximum ECX value for sub-leaves */ *eax = env->cpuid_level_func7; *ebx = env->features[FEAT_7_0_EBX]; /* Feature flags */ @@ -6168,17 +6170,15 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, * support enabling SGX and/or SGX flexible launch control, * then we need to update the VM's CPUID values accordingly. */ - if ((*ebx & CPUID_7_0_EBX_SGX) && - (!kvm_enabled() || - !(kvm_arch_get_supported_cpuid(cs->kvm_state, 0x7, 0, R_EBX) & - CPUID_7_0_EBX_SGX))) { + x86_cpu_get_supported_cpuid(0x7, 0, + &eax_0_unused, &ebx_0, + &ecx_0, &edx_0_unused); + if ((*ebx & CPUID_7_0_EBX_SGX) && !(ebx_0 & CPUID_7_0_EBX_SGX)) { *ebx &= ~CPUID_7_0_EBX_SGX; } - if ((*ecx & CPUID_7_0_ECX_SGX_LC) && - (!(*ebx & CPUID_7_0_EBX_SGX) || !kvm_enabled() || - !(kvm_arch_get_supported_cpuid(cs->kvm_state, 0x7, 0, R_ECX) & - CPUID_7_0_ECX_SGX_LC))) { + if ((*ecx & CPUID_7_0_ECX_SGX_LC) + && (!(*ebx & CPUID_7_0_EBX_SGX) || !(ecx_0 & CPUID_7_0_ECX_SGX_LC))) { *ecx &= ~CPUID_7_0_ECX_SGX_LC; } } else if (count == 1) { @@ -7150,14 +7150,14 @@ static void x86_cpu_filter_features(X86CPU *cpu, bool verbose) mark_unavailable_features(cpu, w, unavailable_features, prefix); } - if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) && - kvm_enabled()) { - KVMState *s = CPU(cpu)->kvm_state; - uint32_t eax_0 = kvm_arch_get_supported_cpuid(s, 0x14, 0, R_EAX); - uint32_t ebx_0 = kvm_arch_get_supported_cpuid(s, 0x14, 0, R_EBX); - uint32_t ecx_0 = kvm_arch_get_supported_cpuid(s, 0x14, 0, R_ECX); - uint32_t eax_1 = kvm_arch_get_supported_cpuid(s, 0x14, 1, R_EAX); - uint32_t ebx_1 = kvm_arch_get_supported_cpuid(s, 0x14, 1, R_EBX); + if (env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) { + uint32_t eax_0, ebx_0, ecx_0, edx_0_unused; + uint32_t eax_1, ebx_1, ecx_1_unused, edx_1_unused; + + x86_cpu_get_supported_cpuid(0x14, 0, + &eax_0, &ebx_0, &ecx_0, &edx_0_unused); + x86_cpu_get_supported_cpuid(0x14, 1, + &eax_1, &ebx_1, &ecx_1_unused, &edx_1_unused); if (!eax_0 || ((ebx_0 & INTEL_PT_MINIMAL_EBX) != INTEL_PT_MINIMAL_EBX) ||