From nobody Wed May 15 18:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653507136; cv=none; d=zohomail.com; s=zohoarc; b=cWa72CDc0MXk1O0ePMmNsERUL42IbJyKg+QJjx2fdcYTFvJPJgfcoo2YE+PMN7C/3G3l2JGUTLoiwWlaiYU8oULpFYf7bHF5jF3WX3Gd0OwLXCZwz1wq5vufvXFexDrjEpX6tbrUyaAw+6QyTQINWgq9rmzF3ULDjyvnU7J8fQ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653507136; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ngKAJ1ClsBYBIb2xn8wk4rk26dUbkChSoPtm42EWb1o=; b=Kp3wXC90HCipnn8pETqG18IzGTWzTQ4HNA03UmjCiakmfjNHXqp5fTy6+qou74MlalqxQgiEIxvszELOBKslaj/pz6M7QcNmaeMS5JZ5RBS9IGe8bbFB6+S4xpzT3k9FH3JwnBnE7q9yYx3ybMc1whTWd4A4WJnyVMiZOh6wj4g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165350713618695.41886295862628; Wed, 25 May 2022 12:32:16 -0700 (PDT) Received: from localhost ([::1]:41994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntwju-0007AY-IZ for importer@patchew.org; Wed, 25 May 2022 15:32:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47324) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwgr-0004Zj-G4 for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42991) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwgo-0003pA-8N for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:03 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-258-vNn2tm9aN7KIYuGn0qFmEw-1; Wed, 25 May 2022 15:28:59 -0400 Received: by mail-ej1-f69.google.com with SMTP id tl4-20020a170907c30400b006ff066327b2so3093639ejc.9 for ; Wed, 25 May 2022 12:28:59 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id n6-20020a170906700600b006fed40e5564sm3864081ejj.83.2022.05.25.12.28.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 12:28:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653506940; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ngKAJ1ClsBYBIb2xn8wk4rk26dUbkChSoPtm42EWb1o=; b=VD7FuWGU2CVy/ZkvQJGL1kw34o93C1e2jX82gRL3xCxBV2VfpLocUwh69yzTrugG7ycUJU FMadWZIra/HQmweBdWHda4rEz7/GFk1dcv2LtBNyWAaLh7KS+gszqRtBn/fb6GqeVjGyLs SjxVIYW9kzzKtCF/C+QjMEDXptHrUdE= X-MC-Unique: vNn2tm9aN7KIYuGn0qFmEw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ngKAJ1ClsBYBIb2xn8wk4rk26dUbkChSoPtm42EWb1o=; b=I0EweTSjo5zChGmWV7awRCRaDcYteEUsbKuTy00zjhFsD8+zruvbcDCwxg67Hv7Goi d+K7sMfdok53TZtYFMpJ+8nAfElnACGHPgYMO8d95+Nvx5sY4faWMN0bL39Z2f00rcqJ nLaHeB/xINt9voaseOgdvGjvDSkDYC/kwda0yf4t/MZmEhh1HopwBMbzmS0caL9cc+EK KxLkiA47MNwEEBX0Xo4xYkaG25IWfTFSMtdal5TC87iezFu9cE41xp/W9WnWqftv2EpQ cpnG//G4sdYaVo2fsGM5IUNr2LQcNu0PN8OHST80cCMbE6Dq4/O4CM6KWsczoegq5hcd RiVg== X-Gm-Message-State: AOAM530HVEsBor1GwKf+U6DsSTp4GmeahFSwgBthwxiNu1yFvQ/DzVgm 0obdmrqJrCVvcLbVZlBqUFor/Xi5bMNjUKTVyYGrCeq2FT+PzkGTejI9y2SN5mUKr6rfo3ZwzV1 oTccxnRAafv0CpE2tQggHqcMJXh8ryd7IbgvWhwdCmTpWAkOz5JfqZMRi6/IV6PHsozM= X-Received: by 2002:a17:906:c209:b0:6fe:a3d5:c5a4 with SMTP id d9-20020a170906c20900b006fea3d5c5a4mr26041587ejz.759.1653506937561; Wed, 25 May 2022 12:28:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygu6IeBWcpD4BjjgVh71MuUzHXSPnkTdYNzWmzxvQEnpGp8H2RIXt9ahysGGDysV8R3cMpSw== X-Received: by 2002:a17:906:c209:b0:6fe:a3d5:c5a4 with SMTP id d9-20020a170906c20900b006fea3d5c5a4mr26041558ejz.759.1653506937209; Wed, 25 May 2022 12:28:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Yang Weijiang Subject: [PULL 01/17] target/i386: Remove LBREn bit check when access Arch LBR MSRs Date: Wed, 25 May 2022 21:28:36 +0200 Message-Id: <20220525192852.301633-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525192852.301633-1-pbonzini@redhat.com> References: <20220525192852.301633-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653507136646100001 Content-Type: text/plain; charset="utf-8" From: Yang Weijiang Live migration can happen when Arch LBR LBREn bit is cleared, e.g., when migration happens after guest entered SMM mode. In this case, we still need to migrate Arch LBR MSRs. Signed-off-by: Yang Weijiang Message-Id: <20220517155024.33270-1-weijiang.yang@intel.com> Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index a9ee8eebd7..e2d675115b 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -3373,15 +3373,14 @@ static int kvm_put_msrs(X86CPU *cpu, int level) int i, ret; =20 /* - * Only migrate Arch LBR states when: 1) Arch LBR is enabled - * for migrated vcpu. 2) the host Arch LBR depth equals that - * of source guest's, this is to avoid mismatch of guest/host - * config for the msr hence avoid unexpected misbehavior. + * Only migrate Arch LBR states when the host Arch LBR depth + * equals that of source guest's, this is to avoid mismatch + * of guest/host config for the msr hence avoid unexpected + * misbehavior. */ ret =3D kvm_get_one_msr(cpu, MSR_ARCH_LBR_DEPTH, &depth); =20 - if (ret =3D=3D 1 && (env->msr_lbr_ctl & 0x1) && !!depth && - depth =3D=3D env->msr_lbr_depth) { + if (ret =3D=3D 1 && !!depth && depth =3D=3D env->msr_lbr_depth= ) { kvm_msr_entry_add(cpu, MSR_ARCH_LBR_CTL, env->msr_lbr_ctl); kvm_msr_entry_add(cpu, MSR_ARCH_LBR_DEPTH, env->msr_lbr_de= pth); =20 @@ -3801,13 +3800,11 @@ static int kvm_get_msrs(X86CPU *cpu) =20 if (kvm_enabled() && cpu->enable_pmu && (env->features[FEAT_7_0_EDX] & CPUID_7_0_EDX_ARCH_LBR)) { - uint64_t ctl, depth; - int i, ret2; + uint64_t depth; + int i, ret; =20 - ret =3D kvm_get_one_msr(cpu, MSR_ARCH_LBR_CTL, &ctl); - ret2 =3D kvm_get_one_msr(cpu, MSR_ARCH_LBR_DEPTH, &depth); - if (ret =3D=3D 1 && ret2 =3D=3D 1 && (ctl & 0x1) && - depth =3D=3D ARCH_LBR_NR_ENTRIES) { + ret =3D kvm_get_one_msr(cpu, MSR_ARCH_LBR_DEPTH, &depth); + if (ret =3D=3D 1 && depth =3D=3D ARCH_LBR_NR_ENTRIES) { kvm_msr_entry_add(cpu, MSR_ARCH_LBR_CTL, 0); kvm_msr_entry_add(cpu, MSR_ARCH_LBR_DEPTH, 0); =20 --=20 2.36.1 From nobody Wed May 15 18:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653507136; cv=none; d=zohomail.com; s=zohoarc; b=YgxuiqrtSZLRnR5KFyE12go+yN+puH2DrcjfEhgsdH7c0Gb4U8nGiuZoK/qZ/JHlwhrN84Z4AePuaT1mtpGyGL+FWzN6BEEgt3MECA6pGLAJtnzFLf+NCeCiA6VVug5MCS0MHIYivjVNOHlkRp2pe5k1EnZosUv3KC0KHjqcklI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653507136; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WTuFEN5hmxoRk6//cGcJ956qKtBJxIwj3v7ZGjAuDK0=; b=XggINKzhs/YeeSeb7zL9Gq316qdLTChp5v+cpUjiPNEb/tezwEWyeCeOxI5rUN6D0DPo46mdUTOkyt6b3kkIF9USXPsTC+d2tBUIUWV3Sngx8HfDOZMuf1pOItXGXBUABou8QImg5r7Ho+7qAclCnJuVH8+txV9i+T4DivLKmho= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1653507136837754.6176506403965; Wed, 25 May 2022 12:32:16 -0700 (PDT) Received: from localhost ([::1]:42138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntwjv-0007Lh-7H for importer@patchew.org; Wed, 25 May 2022 15:32:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwgr-0004a0-U8 for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30784) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwgq-0003pK-59 for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:05 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-668-BuD0p0ogOfGDHc6FUUzrSA-1; Wed, 25 May 2022 15:29:01 -0400 Received: by mail-ej1-f72.google.com with SMTP id gf24-20020a170906e21800b006fe8e7f8783so9597846ejb.2 for ; Wed, 25 May 2022 12:29:01 -0700 (PDT) Received: from goa-sendmail ([93.56.169.184]) by smtp.gmail.com with ESMTPSA id d1-20020a50fb01000000b0042617ba63basm10811098edq.68.2022.05.25.12.28.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 12:28:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653506943; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WTuFEN5hmxoRk6//cGcJ956qKtBJxIwj3v7ZGjAuDK0=; b=N5Ye7M+sMV6ak/umvZskUK88OdgsdPW3vkO8QUAyOnvymnMKWuBLaOv2k0crjyyG3oL/II krOOOMGTpalppifC5vO/dKsKmBm9gpv+wakDeO4A5+CVGX0kMPl26hpQFLCd0CLiItmjv1 qx0Iqo4NQWJTqSgF+3DAFBcqA2sw9sg= X-MC-Unique: BuD0p0ogOfGDHc6FUUzrSA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WTuFEN5hmxoRk6//cGcJ956qKtBJxIwj3v7ZGjAuDK0=; b=K9ZBUMYrgmqZlIAiWrERsnIaGduxUgn/uDI6miwaaCdejPqU4aqK/kkDwh5nWFDGRg FtBR2K7nmid3+bWUhmpC+CnRaaMy5YRObSiczzV1/GwlTyyER//2X9SKJdWeLIkCi0gD 2UEqliAJoasbhDYJJLIEBEudtUTl0fDTUXkr99UScOfUvHA6xY1fvewc60T8MGC0PF5s kxtZ3uC4zg3CA92+WIozPxgiD99hX4CyPSP/vtEoNGLqD68rlljDkjKJbGFaFCqLQ/vV lg2PNqddhwpj9RQ5oB8cgnFyZWRVsFiZOvBPpobct3imKTj7fwslFQ/IgRQoI2CFrJqr 8BLw== X-Gm-Message-State: AOAM531L0wgCX0ZnHHnIj2RTo9i4lbeNkh2FfClehQafo+Ixy0zz6jTP jb36bejyAICDqDOIbqSaA2+pnzX/XICfKFuL5XvpOXg2dscUfbvci4pxOZ5DCqnFPdw9m1/ix/b j6XM3N3U3Oq6FMEUnYvClR7jb74ev8HGfYXwUpFjFfdujSIEgjZFe7B4phZsp66Ej6AA= X-Received: by 2002:a17:906:a5b:b0:6f4:55f6:78af with SMTP id x27-20020a1709060a5b00b006f455f678afmr30577640ejf.238.1653506939645; Wed, 25 May 2022 12:28:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhws+uf3HelGIBGaITfXupbN63Bag1EuYj/e0TyA+2c3Q6vYydiicsWo8UaRaFxv5yV0p3vQ== X-Received: by 2002:a17:906:a5b:b0:6f4:55f6:78af with SMTP id x27-20020a1709060a5b00b006f455f678afmr30577625ejf.238.1653506939391; Wed, 25 May 2022 12:28:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Jaroslav Jindrak Subject: [PULL 02/17] hostmem: default the amount of prealloc-threads to smp-cpus Date: Wed, 25 May 2022 21:28:37 +0200 Message-Id: <20220525192852.301633-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525192852.301633-1-pbonzini@redhat.com> References: <20220525192852.301633-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653507138548100005 Content-Type: text/plain; charset="utf-8" From: Jaroslav Jindrak Prior to the introduction of the prealloc-threads property, the amount of threads used to preallocate memory was derived from the value of smp-cpus passed to qemu, the amount of physical cpus of the host and a hardcoded maximum value. When the prealloc-threads property was introduced, it included a default of 1 in backends/hostmem.c and a default of smp-cpus using the sugar API for the property itself. The latter default is not used when the property is not specified on qemu's command line, so guests that were not adjusted for this change suddenly started to use the default of 1 thread to preallocate memory, which resulted in observable slowdowns in guest boots for guests with large memory (e.g. when using libvirt <8.2.0 or managing guests manually). This commit restores the original behavior for these cases while not impacting guests started with the prealloc-threads property in any way. Fixes: 220c1fd864e9d ("hostmem: introduce "prealloc-threads" property") Signed-off-by: Jaroslav Jindrak Message-Id: <20220517123858.7933-1-dzejrou@gmail.com> Signed-off-by: Paolo Bonzini --- backends/hostmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backends/hostmem.c b/backends/hostmem.c index a7bae3d713..624bb7ecd3 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -274,7 +274,7 @@ static void host_memory_backend_init(Object *obj) backend->merge =3D machine_mem_merge(machine); backend->dump =3D machine_dump_guest_core(machine); backend->reserve =3D true; - backend->prealloc_threads =3D 1; + backend->prealloc_threads =3D machine->smp.cpus; } =20 static void host_memory_backend_post_init(Object *obj) --=20 2.36.1 From nobody Wed May 15 18:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653507339; cv=none; d=zohomail.com; s=zohoarc; b=kFLwbNHvtOhRNPzMzsDOXoaO4rebnlBmeoHGBNj1rW2bH9a+XhtjzOGW726kFRtq+pgk6Mg7LmidsN7A5aTkuBSS7r9xEdzdsv9NEXMShgke+y6b53CJx/6Ul+Nm0GF3uXiYkKjOMYr20v9t1lV5CFrZucxNTrk9re5xFYvVbh0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653507339; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Xc61ioXjJqs4GYPUXx9rha0+l8QYITFxPw67Rmvb6ME=; b=mnbrrGXIPnbPBWCJwM0uiHrfpXd1RuvgyWvBs9lX8Y2dpLYuz/5GM+mnA2U/cLRVZ/QA/RkHxad0AzeqoTMCznHvFcVll53MYBiR9gvBcqLUQmoLfDNrwSRkpqfoXubiNhQp4HSeO89dTJIPFSb4n2wWewUM/i9unlPNLyvuJpE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1653507339209140.43207938106355; Wed, 25 May 2022 12:35:39 -0700 (PDT) Received: from localhost ([::1]:50690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntwnC-0004eg-6W for importer@patchew.org; Wed, 25 May 2022 15:35:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwgt-0004bA-0h for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49871) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwgr-0003pW-ID for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:06 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-104-z--XoHUTNkClVx-rswHMJg-1; Wed, 25 May 2022 15:29:03 -0400 Received: by mail-ej1-f69.google.com with SMTP id ks1-20020a170906f84100b006fee53b22c2so4991729ejb.10 for ; Wed, 25 May 2022 12:29:03 -0700 (PDT) Received: from goa-sendmail ([93.56.169.184]) by smtp.gmail.com with ESMTPSA id hs33-20020a1709073ea100b006feb71acbb3sm5415381ejc.105.2022.05.25.12.29.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 12:29:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653506945; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xc61ioXjJqs4GYPUXx9rha0+l8QYITFxPw67Rmvb6ME=; b=VuZ4bwRmcIpIfjLXglNuC0t6I/ZGJMOkLUd6hlZwrHK2yA4+sn1lYMzZzEmip4BIJ4Fvuu 4p2UXJDie9CFzJif13Cv6hRsSC6F7YxglahYBpUxHLeNMYE0C6FkmLu7UnnZtF3NMAFrC6 1eNUwOR4jeIFFwRepKdRbU6GRkKbCXI= X-MC-Unique: z--XoHUTNkClVx-rswHMJg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Xc61ioXjJqs4GYPUXx9rha0+l8QYITFxPw67Rmvb6ME=; b=sWXre1KygPJntzpRGYqhsIAPah2nbYieev4iI2TQdHJ5F+jBL+dJvrxQvuKflSsRu0 X78uBf3WNrwpDZGP2bn3386fFwnuTKobolQrZzF0gnSxxvmbOMKKWik6gafFFxj0cBQY gt3LRPIUrzCr2HlhwzSk66JJaBMlxfboy0lSLvyehOilldicrvbJaPWIwKBdFpxbmEq0 8KSOswLtTP9GiBMxjnH1F2bGIr1zefCpyyCxiiq6/SuljWcnWMHLaFeJawzVhX0HKfO5 1Fu7lPqSt6RdKCL7MfuX0smDq0zKYjmprpVYACRl1zGhTAtbadIhtqgW8vZXfVMrhPg1 5apA== X-Gm-Message-State: AOAM532pK8jCTQhmohDzTnl6qryBMiUDwiihiCuoA2tZY5+hkiSKWkuu f/tZ7f2qj88VmqmB/pEO0DZPxP9DnoU6zYuQngTNC6MvbPw+kMZOJew/PnZtmia1MJb+rH4dd5U lCKONcoo3I4XG7kE/6eltjRnRD+qWkDj7Pk7tmL4UDPt951BYLEcD/nMgt4YMZTy7avs= X-Received: by 2002:a05:6402:1010:b0:42b:5afd:a506 with SMTP id c16-20020a056402101000b0042b5afda506mr20185942edu.276.1653506941897; Wed, 25 May 2022 12:29:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8WbW8i4iC7KsbComCYTDWfmREO0z7rkmp87oHMSpn05nAgdN0Jc1FTMpjeOb2Zwg08ikcGA== X-Received: by 2002:a05:6402:1010:b0:42b:5afd:a506 with SMTP id c16-20020a056402101000b0042b5afda506mr20185917edu.276.1653506941618; Wed, 25 May 2022 12:29:01 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Nicolas Saenz Julienne Subject: [PULL 03/17] thread-pool: optimize scheduling of completion bottom half Date: Wed, 25 May 2022 21:28:38 +0200 Message-Id: <20220525192852.301633-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525192852.301633-1-pbonzini@redhat.com> References: <20220525192852.301633-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653507339427100001 Content-Type: text/plain; charset="utf-8" The completion bottom half was scheduled within the pool->lock critical section. That actually results in worse performance, because the worker thread can run its own small critical section and go to sleep before the bottom half starts running. Note that this simple change does not produce an improvement without changing the thread pool QemuSemaphore to a condition variable. Reviewed-by: Stefan Hajnoczi Reviewed-by: Nicolas Saenz Julienne Message-Id: <20220514065012.1149539-2-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini --- util/thread-pool.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util/thread-pool.c b/util/thread-pool.c index 196835b4d3..4979f30ca3 100644 --- a/util/thread-pool.c +++ b/util/thread-pool.c @@ -127,9 +127,8 @@ static void *worker_thread(void *opaque) smp_wmb(); req->state =3D THREAD_DONE; =20 - qemu_mutex_lock(&pool->lock); - qemu_bh_schedule(pool->completion_bh); + qemu_mutex_lock(&pool->lock); } =20 pool->cur_threads--; --=20 2.36.1 From nobody Wed May 15 18:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653507349; cv=none; d=zohomail.com; s=zohoarc; b=LyK18/JrtsBnn+Ier9pxXT9f0Xgg+ckLca6ej1GHm53w3jKMIhjGZE6pgJ5n2LSa0khTTG4AEzFQbDxTSNwG7/7b80l6I4fRTi8y/qsWXtEqRQaDxfMhDDqtF4wjA+Obpm9snsLDilaxGrj9SWGoKte3rW0nNKW9EVKYDBA4O0Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653507349; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PCyKr7KYl7rrTx7mVdiORRVc39Z0IumNqgPEAKTb3Uo=; b=gJHU9BxHRvMEIFKT2Pk7wNSmEqd0RKiomYYTwq3gekOVEqgCKDTyi/qGnuIIW4EIRVyG+6gbAj4rS1BFZzTbYgIDWCpMzDBtzXzZUAjWEfXJU4gdPOL6Zewoo+UHzOveYChvmy4vrF04qu7LcqbCF+GdQaWS55D5knOFKKnFhJQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1653507349021963.1083496384274; Wed, 25 May 2022 12:35:49 -0700 (PDT) Received: from localhost ([::1]:51124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntwnL-0004vu-Uc for importer@patchew.org; Wed, 25 May 2022 15:35:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwgz-0004qX-0N for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28519) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwgx-0003pv-3Z for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:12 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-540-JAfAnKWjNvacFglRqc6o-w-1; Wed, 25 May 2022 15:29:09 -0400 Received: by mail-ej1-f70.google.com with SMTP id qn6-20020a170907870600b006ff0d367555so1966471ejc.8 for ; Wed, 25 May 2022 12:29:07 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id s23-20020a056402015700b0042ab1735552sm11005752edu.66.2022.05.25.12.29.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 12:29:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653506950; 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=PCyKr7KYl7rrTx7mVdiORRVc39Z0IumNqgPEAKTb3Uo=; b=SD3RQ6FxmJp1FZ0eW7Zz021DBLpNn1n/Ty1yHK9o0PA10sp0Kv2zYockKFMR1itjsb9fNJ o5RIfoVGnNzq6D5BIBbBQAeIvddC/Sv9IyXwx18Lsk1D9uEidBrjBbh2Rluu/uO5z/+VCt jVDiLEUnIgnwMp7vBFF6jw4+tKa7SLI= X-MC-Unique: JAfAnKWjNvacFglRqc6o-w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PCyKr7KYl7rrTx7mVdiORRVc39Z0IumNqgPEAKTb3Uo=; b=hXGVfCoRE/nIuCLx2oSnyQwJWEvyfs0BzM6JvqS2bgRE0IvYyfgqfCWOGW2GhAgniC OMFANmT82XzKjCF6PysrgB5FuZtr82lvYHoyRGpxOXFHecvdD3F/+YcqxLnIPjLjwYWV I5ZqCZu+EIJCoiUD6ZaHZtW1h3bti4hrPsjXh3T9f6/8VFTWLEd54crxl8M09UqDVoWn cEVqMDdpSC1OSxPafCEmw49Lae1vSe9fYSyYNBBiEEAplDb0kjGMhOM6RuFJAH+EgAsb /el1Rqr1E/VL0lxvIW9jfZdm0//tlwqjCIhae9oQV6PMLJZNg2dgLQTmNMcTzQNYRjso n+hg== X-Gm-Message-State: AOAM5331qHHNHU5J8eW21RVtuJEjFsSj+AVsP9KnDetweRYfWXJ2TESO OL3fK1U+nsLkfO1VZrQTKJQyXw0rLqZFr5geSqqZ0tK9t9R6ho+jKEiIJDhnsFtpLeQjxMyqc0J jRcOTijuoKEqapIYUGgdrJ8GwMXDZ5QHvFgTMCG1OEB3a15Vk/LFLL2NIyFgdB8xBsec= X-Received: by 2002:a05:6402:896:b0:42b:a9e1:a60b with SMTP id e22-20020a056402089600b0042ba9e1a60bmr7776838edy.394.1653506946294; Wed, 25 May 2022 12:29:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGEfjznm4OMOs1ScgNEBHkR6Lzy8B4PKewO9ZJ5XjcT5/0d3JMDLfFqB1grGpX7MX6SY0htg== X-Received: by 2002:a05:6402:896:b0:42b:a9e1:a60b with SMTP id e22-20020a056402089600b0042ba9e1a60bmr7776813edy.394.1653506945929; Wed, 25 May 2022 12:29:05 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Stefan Hajnoczi , Nicolas Saenz Julienne Subject: [PULL 04/17] thread-pool: replace semaphore with condition variable Date: Wed, 25 May 2022 21:28:39 +0200 Message-Id: <20220525192852.301633-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525192852.301633-1-pbonzini@redhat.com> References: <20220525192852.301633-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PP_MIME_FAKE_ASCII_TEXT=0.999, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653507349437100001 Since commit f9fc8932b1 ("thread-posix: remove the posix semaphore support", 2022-04-06) QemuSemaphore has its own mutex and condition variable; this adds unnecessary overhead on I/O with small block sizes. Check the QTAILQ directly instead of adding the indirection of a semaphore's count. Using a semaphore has not been necessary since qemu_cond_timedwait was introduced; the new code has to be careful about spurious wakeups but it is simpler, for example thread_pool_cancel does not have to worry about synchronizing the semaphore count with the number of elements of pool->request_list. Note that the return value of qemu_cond_timedwait (0 for timeout, 1 for signal or spurious wakeup) is different from that of qemu_sem_timedwait (-1 for timeout, 0 for success). Reported-by: Luk=C3=A1=C5=A1 Doktor Suggested-by: Stefan Hajnoczi Reviewed-by: Nicolas Saenz Julienne Message-Id: <20220514065012.1149539-3-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini --- util/thread-pool.c | 68 +++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 40 deletions(-) diff --git a/util/thread-pool.c b/util/thread-pool.c index 4979f30ca3..6e3d4e4a2f 100644 --- a/util/thread-pool.c +++ b/util/thread-pool.c @@ -57,7 +57,7 @@ struct ThreadPool { QEMUBH *completion_bh; QemuMutex lock; QemuCond worker_stopped; - QemuSemaphore sem; + QemuCond request_cond; QEMUBH *new_thread_bh; =20 /* The following variables are only accessed from one AioContext. */ @@ -74,23 +74,6 @@ struct ThreadPool { int max_threads; }; =20 -static inline bool back_to_sleep(ThreadPool *pool, int ret) -{ - /* - * The semaphore timed out, we should exit the loop except when: - * - There is work to do, we raced with the signal. - * - The max threads threshold just changed, we raced with the signal. - * - The thread pool forces a minimum number of readily available thr= eads. - */ - if (ret =3D=3D -1 && (!QTAILQ_EMPTY(&pool->request_list) || - pool->cur_threads > pool->max_threads || - pool->cur_threads <=3D pool->min_threads)) { - return true; - } - - return false; -} - static void *worker_thread(void *opaque) { ThreadPool *pool =3D opaque; @@ -99,20 +82,25 @@ static void *worker_thread(void *opaque) pool->pending_threads--; do_spawn_thread(pool); =20 - while (!pool->stopping) { + while (!pool->stopping && pool->cur_threads <=3D pool->max_threads) { ThreadPoolElement *req; int ret; =20 - do { + if (QTAILQ_EMPTY(&pool->request_list)) { pool->idle_threads++; - qemu_mutex_unlock(&pool->lock); - ret =3D qemu_sem_timedwait(&pool->sem, 10000); - qemu_mutex_lock(&pool->lock); + ret =3D qemu_cond_timedwait(&pool->request_cond, &pool->lock, = 10000); pool->idle_threads--; - } while (back_to_sleep(pool, ret)); - if (ret =3D=3D -1 || pool->stopping || - pool->cur_threads > pool->max_threads) { - break; + if (ret =3D=3D 0 && + QTAILQ_EMPTY(&pool->request_list) && + pool->cur_threads > pool->min_threads) { + /* Timed out + no work to do + no need for warm threads = =3D exit. */ + break; + } + /* + * Even if there was some work to do, check if there aren't + * too many worker threads before picking it up. + */ + continue; } =20 req =3D QTAILQ_FIRST(&pool->request_list); @@ -134,6 +122,12 @@ static void *worker_thread(void *opaque) pool->cur_threads--; qemu_cond_signal(&pool->worker_stopped); qemu_mutex_unlock(&pool->lock); + + /* + * Wake up another thread, in case we got a wakeup but decided + * to exit due to pool->cur_threads > pool->max_threads. + */ + qemu_cond_signal(&pool->request_cond); return NULL; } =20 @@ -229,13 +223,7 @@ static void thread_pool_cancel(BlockAIOCB *acb) trace_thread_pool_cancel(elem, elem->common.opaque); =20 QEMU_LOCK_GUARD(&pool->lock); - if (elem->state =3D=3D THREAD_QUEUED && - /* No thread has yet started working on elem. we can try to "steal" - * the item from the worker if we can get a signal from the - * semaphore. Because this is non-blocking, we can do it with - * the lock taken and ensure that elem will remain THREAD_QUEUED. - */ - qemu_sem_timedwait(&pool->sem, 0) =3D=3D 0) { + if (elem->state =3D=3D THREAD_QUEUED) { QTAILQ_REMOVE(&pool->request_list, elem, reqs); qemu_bh_schedule(pool->completion_bh); =20 @@ -280,7 +268,7 @@ BlockAIOCB *thread_pool_submit_aio(ThreadPool *pool, } QTAILQ_INSERT_TAIL(&pool->request_list, req, reqs); qemu_mutex_unlock(&pool->lock); - qemu_sem_post(&pool->sem); + qemu_cond_signal(&pool->request_cond); return &req->common; } =20 @@ -323,7 +311,7 @@ void thread_pool_update_params(ThreadPool *pool, AioCon= text *ctx) * We either have to: * - Increase the number available of threads until over the min_thre= ads * threshold. - * - Decrease the number of available threads until under the max_thr= eads + * - Bump the worker threads so that they exit, until under the max_t= hreads * threshold. * - Do nothing. The current number of threads fall in between the mi= n and * max thresholds. We'll let the pool manage itself. @@ -333,7 +321,7 @@ void thread_pool_update_params(ThreadPool *pool, AioCon= text *ctx) } =20 for (int i =3D pool->cur_threads; i > pool->max_threads; i--) { - qemu_sem_post(&pool->sem); + qemu_cond_signal(&pool->request_cond); } =20 qemu_mutex_unlock(&pool->lock); @@ -350,7 +338,7 @@ static void thread_pool_init_one(ThreadPool *pool, AioC= ontext *ctx) pool->completion_bh =3D aio_bh_new(ctx, thread_pool_completion_bh, poo= l); qemu_mutex_init(&pool->lock); qemu_cond_init(&pool->worker_stopped); - qemu_sem_init(&pool->sem, 0); + qemu_cond_init(&pool->request_cond); pool->new_thread_bh =3D aio_bh_new(ctx, spawn_thread_bh_fn, pool); =20 QLIST_INIT(&pool->head); @@ -383,15 +371,15 @@ void thread_pool_free(ThreadPool *pool) =20 /* Wait for worker threads to terminate */ pool->stopping =3D true; + qemu_cond_broadcast(&pool->request_cond); while (pool->cur_threads > 0) { - qemu_sem_post(&pool->sem); qemu_cond_wait(&pool->worker_stopped, &pool->lock); } =20 qemu_mutex_unlock(&pool->lock); =20 qemu_bh_delete(pool->completion_bh); - qemu_sem_destroy(&pool->sem); + qemu_cond_destroy(&pool->request_cond); qemu_cond_destroy(&pool->worker_stopped); qemu_mutex_destroy(&pool->lock); g_free(pool); --=20 2.36.1 From nobody Wed May 15 18:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653507561; cv=none; d=zohomail.com; s=zohoarc; b=KeXuanpjEnuflpNcgf5DIylTU1FIiFltHsLNEFd7JA0mISBzLAYvsCWIUFbE+YbxHUGWMQopK7TTdzmoIlxl1N1dPLYM+kGGG2fKURnnX0AZ4olbP8goKrrsEEDiZDEc4OeEfDPewNoGw52mD/LmCCH/wdohQ6/P09kRH7NBkzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653507561; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mkUlZaj01t2bCfTppKPLk/Ku3NdW+VbBibGk84xlesw=; b=TyQ0K8o6BAVo45kqpeATGR1i1lUXYSgY6AXO3F9rLbXULeLh90Z1PK4y9PNHA05M0dk4Eg6GkbRux0iC4kPMVe+Jjbd5ytKdvQ3B/eL7c4W+exDe2BbbXdB8BvIHnVtxq4qw0viZJsKONFmezsd9W7RgXty8wuSBrLfwy4NzwoI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1653507561681694.7863590065589; Wed, 25 May 2022 12:39:21 -0700 (PDT) Received: from localhost ([::1]:59380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntwqm-0002EU-68 for importer@patchew.org; Wed, 25 May 2022 15:39:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwh0-0004uj-8F for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24175) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwgy-0003qC-NY for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:13 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-54-yTJnJVXfPkKgcPe8_mR-Jw-1; Wed, 25 May 2022 15:29:10 -0400 Received: by mail-ej1-f71.google.com with SMTP id gs6-20020a170906f18600b006fe7a9ffacbso9893286ejb.3 for ; Wed, 25 May 2022 12:29:10 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id gv45-20020a1709072bed00b006fe9e717143sm6770986ejc.94.2022.05.25.12.29.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 12:29:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653506952; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mkUlZaj01t2bCfTppKPLk/Ku3NdW+VbBibGk84xlesw=; b=aAarSp0jRCT3qDOalhCFwqSQ8INnF/fqrJfU5H/rJ1QDb2U5sJTp+0XLY9MVYUHWZktxQQ KD9baCt1uruT+LMo9MuCuofAGQPpyB81DiWRNK/o/dK3bV/ZGHUNE/XrI2p2X0TFm3vPUd F+28kMVBAsMEds5uMQTdRffmKo/wqsE= X-MC-Unique: yTJnJVXfPkKgcPe8_mR-Jw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mkUlZaj01t2bCfTppKPLk/Ku3NdW+VbBibGk84xlesw=; b=BLqdtSlppaXLc3l7uhKlNiuOkjRzg5AD/v6IIv/HqVj367JuLt7klP450U7AxqHJmp uoodMwIld+uoLnPAVqmhuYfAnYWTDSwuHSPaMVTjuqrt76g/PcEh+yhgIwtz4VeQDzGL SRQIzn2tefixHck7PCCMsA0jdvv467ohiQkzsvzFDZ3MJ+Tnx/U5an60SDWiqZfMHfE0 4fArRplh+WLOkPmsz3J7aFxxcaMAKPKm7cEkp2pFYlIEUKJpZCbRnQFTLH5bsrnogU/d Ysp2IXAheDA7dK0TSj7H8cmGmKACLU+vSlo7OxOADTQ9MlqZpdCbOfw6TTANi6UjWx8d 7+VQ== X-Gm-Message-State: AOAM533K3DlftQwpjqglIghK6RsXfYDGeV6uqCrF4lWIIjgc9AeQfvp2 b6obiI06YQEJcRMsYF6eQFZkvZgSN1KniaGDzNWdqSrYJ8yO4E9tHSm5Gj86nNrZ+1dbvgPSZUv 25MyS9xHk5DSsLMtezoUnC6igfULtV6nNO+lhACdpgJvuylBY/aTr17Cb7focsvSkaNg= X-Received: by 2002:a05:6402:370c:b0:42a:adfa:9150 with SMTP id ek12-20020a056402370c00b0042aadfa9150mr36180278edb.57.1653506948177; Wed, 25 May 2022 12:29:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5HQEU/sgYYRFjLfpVLF/p41umNAM8fm4Qd+eVdifB2xNEEJqHDtajXat1n6VKzazh3D5TLg== X-Received: by 2002:a05:6402:370c:b0:42a:adfa:9150 with SMTP id ek12-20020a056402370c00b0042aadfa9150mr36180263edb.57.1653506947928; Wed, 25 May 2022 12:29:07 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Nicolas Saenz Julienne Subject: [PULL 05/17] thread-pool: remove stopping variable Date: Wed, 25 May 2022 21:28:40 +0200 Message-Id: <20220525192852.301633-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525192852.301633-1-pbonzini@redhat.com> References: <20220525192852.301633-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653507562699100001 Content-Type: text/plain; charset="utf-8" Just setting the max threads to 0 is enough to stop all workers. Message-Id: <20220514065012.1149539-4-pbonzini@redhat.com> Reviewed-by: Stefan Hajnoczi Reviewed-by: Nicolas Saenz Julienne Signed-off-by: Paolo Bonzini --- util/thread-pool.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/util/thread-pool.c b/util/thread-pool.c index 6e3d4e4a2f..31113b5860 100644 --- a/util/thread-pool.c +++ b/util/thread-pool.c @@ -69,7 +69,6 @@ struct ThreadPool { int idle_threads; int new_threads; /* backlog of threads we need to create */ int pending_threads; /* threads created but not running yet */ - bool stopping; int min_threads; int max_threads; }; @@ -82,7 +81,7 @@ static void *worker_thread(void *opaque) pool->pending_threads--; do_spawn_thread(pool); =20 - while (!pool->stopping && pool->cur_threads <=3D pool->max_threads) { + while (pool->cur_threads <=3D pool->max_threads) { ThreadPoolElement *req; int ret; =20 @@ -370,7 +369,7 @@ void thread_pool_free(ThreadPool *pool) pool->new_threads =3D 0; =20 /* Wait for worker threads to terminate */ - pool->stopping =3D true; + pool->max_threads =3D 0; qemu_cond_broadcast(&pool->request_cond); while (pool->cur_threads > 0) { qemu_cond_wait(&pool->worker_stopped, &pool->lock); --=20 2.36.1 From nobody Wed May 15 18:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653507577; cv=none; d=zohomail.com; s=zohoarc; b=fG2iBOgGh/CKgegq9u5Qg9E/wOXe0B7ocGj3DLIeYXdZbvtD33usfwAX2Y1A5Zx+pXPsGp75hbDfY75oB1U81H1mffnPgU4ez0X9dQ7NDQQCk/8ouwU/WhQBvxFL194YER4Y8yE/McuEjI6rTRhaqKcM1+MWSb4clKGiNPsFGX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653507577; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wtZdJzeKJoyGwpmhFItxc7PeNKZ/W7P7ouilE2b374E=; b=T843bGw//pQQ1EkBv2wIKSwhM1w6gjDTXuaHhcAX4il+SbQfOtCSuOZa6PqPVq3OSQK0X1iJPvSWdgjvTNCmpxXzyZTYx/abNp0lfWhaRpKTl/7w+x7APv+BkkIVq7XAO2qPDFWex0QjVZ8DdnL8oPR9EcoY6U6FuGRhMmM/ojw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1653507577306915.9035270682738; Wed, 25 May 2022 12:39:37 -0700 (PDT) Received: from localhost ([::1]:59632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntwr1-0002PL-LI for importer@patchew.org; Wed, 25 May 2022 15:39:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwh3-00052I-FI for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:60263) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwh1-0003qm-5g for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:17 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-177-OR_CtIRqNEK-sIIbG00QXw-1; Wed, 25 May 2022 15:29:13 -0400 Received: by mail-ed1-f70.google.com with SMTP id j22-20020aa7ca56000000b0042bd3527f2aso420354edt.0 for ; Wed, 25 May 2022 12:29:13 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id h18-20020a17090619d200b006f3ef214df2sm5224162ejd.88.2022.05.25.12.29.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 12:29:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653506954; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wtZdJzeKJoyGwpmhFItxc7PeNKZ/W7P7ouilE2b374E=; b=UQt0kOyHxEeSsCTkPifHDxFjywcPY9yS6fn3pMPgN2v5FGUSkK+s3RLlyQr6cySo/fDSZS YJgWEP3DWw3yFFfj6Sz+qiR5Nh/EpH4M1SmIbruMz8AGfnP+OUgW0hixEK8zufT/Wa/2r8 xTn2FusHBVBsitT6rkA11IKubzCNMrA= X-MC-Unique: OR_CtIRqNEK-sIIbG00QXw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wtZdJzeKJoyGwpmhFItxc7PeNKZ/W7P7ouilE2b374E=; b=psk1uR+LzMQTK5U+CO10hJ2OX+wQzVhjwzP/6ePqwGh1KjQZL/juaQG7EsKj6rZbn2 78AYIJxAstEMpFOacesS8FR8UOnoRURMHUcuF4iI8T7gZgAK7dksu0VCfo28D3iicFo9 Br8JsHLXw1YXZJqmJq7ecRXOzVnA+opjKLkiqfKCbyzlFy04gZVtSIWbszDAE/XNFTyu OzKt8U/ntOSEchuE13aamVenF02LceBlT8osa8dskwFl5gcitECu0njE8/xiQhjl4UHC 23HYOg90ljKnfoiBT+GDHjmYq5D8UUVgitrUbwBalSDy61nLxKHYg2kcAQv7GaHy9nrH 2ioQ== X-Gm-Message-State: AOAM531ezMDmyJymQml/UPv1inKhLBy2KP9/adfVXuh7NPQtDneZ4S/6 k4zyt4GavIxx0gHVkHZVSsyVmfubbjPTAYtLX6p7VxMKIi3NrGcQSlNLsZN64QBWv6g52hTtRNY ZTc73SIJwLBeDssH9fuSPJkGTfvpSom66F9irskvb2MCgsOwf99gSMlWF6u1lLnC+8nY= X-Received: by 2002:a05:6402:1010:b0:42b:5afd:a506 with SMTP id c16-20020a056402101000b0042b5afda506mr20186596edu.276.1653506951672; Wed, 25 May 2022 12:29:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdhkAnbXitZXdy5PUo4kLFTnTw9GbP7zhW+KLwQuZfeBde8y3dULEsCcQLflQA/LvQNIsDXg== X-Received: by 2002:a05:6402:1010:b0:42b:5afd:a506 with SMTP id c16-20020a056402101000b0042b5afda506mr20186536edu.276.1653506950951; Wed, 25 May 2022 12:29:10 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Viktor Prutyanov , Richard Henderson Subject: [PULL 06/17] contrib/elf2dmp: add ELF dump header checking Date: Wed, 25 May 2022 21:28:41 +0200 Message-Id: <20220525192852.301633-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525192852.301633-1-pbonzini@redhat.com> References: <20220525192852.301633-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653507578844100001 Content-Type: text/plain; charset="utf-8" From: Viktor Prutyanov Add ELF header checking to prevent processing input file which is not QEMU x86_64 guest memory dump or even not ELF. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1013 Signed-off-by: Viktor Prutyanov Reviewed-by: Richard Henderson Message-Id: <20220520084339.171684-1-viktor.prutyanov@redhat.com> Signed-off-by: Paolo Bonzini --- contrib/elf2dmp/qemu_elf.c | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/contrib/elf2dmp/qemu_elf.c b/contrib/elf2dmp/qemu_elf.c index b601b6d7ba..ebda60dcb8 100644 --- a/contrib/elf2dmp/qemu_elf.c +++ b/contrib/elf2dmp/qemu_elf.c @@ -118,6 +118,53 @@ static void exit_states(QEMU_Elf *qe) free(qe->state); } =20 +static bool check_ehdr(QEMU_Elf *qe) +{ + Elf64_Ehdr *ehdr =3D qe->map; + + if (sizeof(Elf64_Ehdr) > qe->size) { + eprintf("Invalid input dump file size\n"); + return false; + } + + if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG)) { + eprintf("Invalid ELF signature, input file is not ELF\n"); + return false; + } + + if (ehdr->e_ident[EI_CLASS] !=3D ELFCLASS64 || + ehdr->e_ident[EI_DATA] !=3D ELFDATA2LSB) { + eprintf("Invalid ELF class or byte order, must be 64-bit LE\n"); + return false; + } + + if (ehdr->e_ident[EI_VERSION] !=3D EV_CURRENT) { + eprintf("Invalid ELF version\n"); + return false; + } + + if (ehdr->e_machine !=3D EM_X86_64) { + eprintf("Invalid input dump architecture, only x86_64 is supported= \n"); + return false; + } + + if (ehdr->e_type !=3D ET_CORE) { + eprintf("Invalid ELF type, must be core file\n"); + return false; + } + + /* + * ELF dump file must contain one PT_NOTE and at least one PT_LOAD to + * restore physical address space. + */ + if (ehdr->e_phnum < 2) { + eprintf("Invalid number of ELF program headers\n"); + return false; + } + + return true; +} + int QEMU_Elf_init(QEMU_Elf *qe, const char *filename) { GError *gerr =3D NULL; @@ -133,6 +180,12 @@ int QEMU_Elf_init(QEMU_Elf *qe, const char *filename) qe->map =3D g_mapped_file_get_contents(qe->gmf); qe->size =3D g_mapped_file_get_length(qe->gmf); =20 + if (!check_ehdr(qe)) { + eprintf("Input file has the wrong format\n"); + err =3D 1; + goto out_unmap; + } + if (init_states(qe)) { eprintf("Failed to extract QEMU CPU states\n"); err =3D 1; --=20 2.36.1 From nobody Wed May 15 18:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653507388; cv=none; d=zohomail.com; s=zohoarc; b=lSsh8s6+hBcos4rfmK3ps+QdhRzE6HmPYFae4pdu/+/27qz0DXRVjBw9wf1WpmLYei3VOEB/DaufI++oSdMbnOlo5VLK5Z0bZqxoPdAQNvxNZvL4svkibua6S4yHa6/AnQ35cl6vtg1GNkdgHJWCQ7jUNtofN9baaE6wQkNI2Qo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653507388; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kBeYLCHEdhVWRlaeUcbMf0r0YHfh7nu14qSvETeYDeg=; b=nukF2MfT9IlJErjWWfTwez5qWperi1ac0NYwA9kfWwm9nnxd21L7aVMbkbeVNxabV+d1TMEZvfJgh4m81Zvf5x0PrXzwBotbc1mafecc59toZfeAj7zp1CWE2g4MFWb85qgZV37PomUzk84MarpuQvnhODI2WxYvLERZzuS8sws= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1653507388432748.0029550667193; Wed, 25 May 2022 12:36:28 -0700 (PDT) Received: from localhost ([::1]:52352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntwnz-0005pd-6Q for importer@patchew.org; Wed, 25 May 2022 15:36:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwh9-0005GP-EB for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21587) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwh4-0003rC-Cq for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:22 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-302-ZrrrXRk6N7WE2FG96Wrhyw-1; Wed, 25 May 2022 15:29:16 -0400 Received: by mail-ed1-f71.google.com with SMTP id w23-20020aa7da57000000b0042acd76347bso15453380eds.2 for ; Wed, 25 May 2022 12:29:16 -0700 (PDT) Received: from goa-sendmail ([93.56.169.184]) by smtp.gmail.com with ESMTPSA id iy18-20020a170907819200b006fee194c877sm3456668ejc.162.2022.05.25.12.29.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 12:29:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653506957; 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=kBeYLCHEdhVWRlaeUcbMf0r0YHfh7nu14qSvETeYDeg=; b=LfCL2x2j6XFZ08YhFilTTbU97GOj2vjGf0r7X7og9Em5C7iJUlntTv550eEiDuCIxLKFIe KmjgpsiH0saYpdYLiQHU64zffKkV7W5Y4rp9CYrFFkVVtS9CDzZz550T1duSanTTDQxZOt CeUBp2DGDw1q48Oal1XzsaXiqwlaAaY= X-MC-Unique: ZrrrXRk6N7WE2FG96Wrhyw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kBeYLCHEdhVWRlaeUcbMf0r0YHfh7nu14qSvETeYDeg=; b=50weP8XJaiawEKMZtcsmg9qzZ6XqC04jzC3ydzFkddJzbdrY+OF6MIZX/7F23Ajm09 FdQRAk2XCqZaKgDKbEtDy3jAqGTWY6tYJS9CkrewO/k4dhMKnNkBU/146qyaHDr1kywX qs207TPFG3q5LZDQgCi4L27b1Cgudr5NRLXUvF7ovkRUhXHLW0DI1AL62lmqCzCxa8tv GJBcq8D3t2dclioaUAONMTx9VDAg/Ar32f9bC1SpIx2aBtJAOG5ULX/frbFEKWYFepIi BEeKVgf0JY9XiYV/XcbqjQTUT92UUFZbnZVA9srfIxyMBrOhmrDkWZA70n0t22cUaICO TZAQ== X-Gm-Message-State: AOAM530m9EW8a8u05QgPM5djKmD9zmiKofHsLT4W93JqhIfzTniIp3iC 5/dqSMgQs/e43CZNhENApOlFFlOsZUA4nMFGuDXg9jH5W7lfggkXzKwC3ZbNPuU0oqp6A5B4B8G KhEQpu+nPXx+Nd12zYfF1y+curXOGRkzsPtAJdGR7Sv3FZ8r9nXcTiWpSBtO0ebDh8gE= X-Received: by 2002:aa7:c68d:0:b0:42b:cc77:4696 with SMTP id n13-20020aa7c68d000000b0042bcc774696mr3881905edq.320.1653506954010; Wed, 25 May 2022 12:29:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJye7bELYujEbGH9WXjI/ncl+xYek8j3Oem9HR/ZPNTl1kFRo8L+wH2BpTv73p2sphg4KZs3rw== X-Received: by 2002:aa7:c68d:0:b0:42b:cc77:4696 with SMTP id n13-20020aa7c68d000000b0042bcc774696mr3881851edq.320.1653506953185; Wed, 25 May 2022 12:29:13 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: BALATON Zoltan , =?UTF-8?q?V=C3=ADctor=20Colombo?= Subject: [PULL 07/17] hw/audio/ac97: Coding style fixes to avoid checkpatch errors Date: Wed, 25 May 2022 21:28:42 +0200 Message-Id: <20220525192852.301633-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525192852.301633-1-pbonzini@redhat.com> References: <20220525192852.301633-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PP_MIME_FAKE_ASCII_TEXT=0.999, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653507389739100001 From: BALATON Zoltan Signed-off-by: BALATON Zoltan Reviewed-by: V=C3=ADctor Colombo Message-Id: <62862a057e9c9ec0bb45248b2b9a3a1babb346a6.1650706617.git.balato= n@eik.bme.hu> Signed-off-by: Paolo Bonzini --- hw/audio/ac97.c | 727 ++++++++++++++++++++++++------------------------ 1 file changed, 357 insertions(+), 370 deletions(-) diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c index 3cb8131060..6b1c12bece 100644 --- a/hw/audio/ac97.c +++ b/hw/audio/ac97.c @@ -87,39 +87,39 @@ enum { #define GC_CR 2 /* rw */ #define GC_VALID_MASK ((1 << 6) - 1) =20 -#define GS_MD3 (1<<17) /* rw */ -#define GS_AD3 (1<<16) /* rw */ -#define GS_RCS (1<<15) /* rwc */ -#define GS_B3S12 (1<<14) /* ro */ -#define GS_B2S12 (1<<13) /* ro */ -#define GS_B1S12 (1<<12) /* ro */ -#define GS_S1R1 (1<<11) /* rwc */ -#define GS_S0R1 (1<<10) /* rwc */ -#define GS_S1CR (1<<9) /* ro */ -#define GS_S0CR (1<<8) /* ro */ -#define GS_MINT (1<<7) /* ro */ -#define GS_POINT (1<<6) /* ro */ -#define GS_PIINT (1<<5) /* ro */ -#define GS_RSRVD ((1<<4)|(1<<3)) -#define GS_MOINT (1<<2) /* ro */ -#define GS_MIINT (1<<1) /* ro */ +#define GS_MD3 (1 << 17) /* rw */ +#define GS_AD3 (1 << 16) /* rw */ +#define GS_RCS (1 << 15) /* rwc */ +#define GS_B3S12 (1 << 14) /* ro */ +#define GS_B2S12 (1 << 13) /* ro */ +#define GS_B1S12 (1 << 12) /* ro */ +#define GS_S1R1 (1 << 11) /* rwc */ +#define GS_S0R1 (1 << 10) /* rwc */ +#define GS_S1CR (1 << 9) /* ro */ +#define GS_S0CR (1 << 8) /* ro */ +#define GS_MINT (1 << 7) /* ro */ +#define GS_POINT (1 << 6) /* ro */ +#define GS_PIINT (1 << 5) /* ro */ +#define GS_RSRVD ((1 << 4) | (1 << 3)) +#define GS_MOINT (1 << 2) /* ro */ +#define GS_MIINT (1 << 1) /* ro */ #define GS_GSCI 1 /* rwc */ -#define GS_RO_MASK (GS_B3S12| \ - GS_B2S12| \ - GS_B1S12| \ - GS_S1CR| \ - GS_S0CR| \ - GS_MINT| \ - GS_POINT| \ - GS_PIINT| \ - GS_RSRVD| \ - GS_MOINT| \ +#define GS_RO_MASK (GS_B3S12 | \ + GS_B2S12 | \ + GS_B1S12 | \ + GS_S1CR | \ + GS_S0CR | \ + GS_MINT | \ + GS_POINT | \ + GS_PIINT | \ + GS_RSRVD | \ + GS_MOINT | \ GS_MIINT) #define GS_VALID_MASK ((1 << 18) - 1) -#define GS_WCLEAR_MASK (GS_RCS|GS_S1R1|GS_S0R1|GS_GSCI) +#define GS_WCLEAR_MASK (GS_RCS | GS_S1R1 | GS_S0R1 | GS_GSCI) =20 -#define BD_IOC (1<<31) -#define BD_BUP (1<<30) +#define BD_IOC (1 << 31) +#define BD_BUP (1 << 30) =20 #define EACS_VRA 1 #define EACS_VRM 8 @@ -183,7 +183,7 @@ enum { }; =20 #ifdef DEBUG_AC97 -#define dolog(...) AUD_log ("ac97", __VA_ARGS__) +#define dolog(...) AUD_log("ac97", __VA_ARGS__) #else #define dolog(...) #endif @@ -206,9 +206,9 @@ enum { LAST_INDEX }; =20 -MKREGS (PI, PI_INDEX * 16); -MKREGS (PO, PO_INDEX * 16); -MKREGS (MC, MC_INDEX * 16); +MKREGS(PI, PI_INDEX * 16); +MKREGS(PO, PO_INDEX * 16); +MKREGS(MC, MC_INDEX * 16); =20 enum { GLOB_CNT =3D 0x2c, @@ -218,36 +218,35 @@ enum { =20 #define GET_BM(index) (((index) >> 4) & 3) =20 -static void po_callback (void *opaque, int free); -static void pi_callback (void *opaque, int avail); -static void mc_callback (void *opaque, int avail); +static void po_callback(void *opaque, int free); +static void pi_callback(void *opaque, int avail); +static void mc_callback(void *opaque, int avail); =20 -static void warm_reset (AC97LinkState *s) +static void warm_reset(AC97LinkState *s) { - (void) s; + (void)s; } =20 -static void cold_reset (AC97LinkState * s) +static void cold_reset(AC97LinkState *s) { - (void) s; + (void)s; } =20 -static void fetch_bd (AC97LinkState *s, AC97BusMasterRegs *r) +static void fetch_bd(AC97LinkState *s, AC97BusMasterRegs *r) { uint8_t b[8]; =20 - pci_dma_read (&s->dev, r->bdbar + r->civ * 8, b, 8); + pci_dma_read(&s->dev, r->bdbar + r->civ * 8, b, 8); r->bd_valid =3D 1; - r->bd.addr =3D le32_to_cpu (*(uint32_t *) &b[0]) & ~3; - r->bd.ctl_len =3D le32_to_cpu (*(uint32_t *) &b[4]); + r->bd.addr =3D le32_to_cpu(*(uint32_t *) &b[0]) & ~3; + r->bd.ctl_len =3D le32_to_cpu(*(uint32_t *) &b[4]); r->picb =3D r->bd.ctl_len & 0xffff; - dolog ("bd %2d addr=3D%#x ctl=3D%#06x len=3D%#x(%d bytes)\n", - r->civ, r->bd.addr, r->bd.ctl_len >> 16, - r->bd.ctl_len & 0xffff, - (r->bd.ctl_len & 0xffff) << 1); + dolog("bd %2d addr=3D0x%x ctl=3D0x%06x len=3D0x%x(%d bytes)\n", + r->civ, r->bd.addr, r->bd.ctl_len >> 16, + r->bd.ctl_len & 0xffff, (r->bd.ctl_len & 0xffff) << 1); } =20 -static void update_sr (AC97LinkState *s, AC97BusMasterRegs *r, uint32_t ne= w_sr) +static void update_sr(AC97LinkState *s, AC97BusMasterRegs *r, uint32_t new= _sr) { int event =3D 0; int level =3D 0; @@ -260,8 +259,7 @@ static void update_sr (AC97LinkState *s, AC97BusMasterR= egs *r, uint32_t new_sr) if (!new_mask) { event =3D 1; level =3D 0; - } - else { + } else { if ((new_mask & SR_LVBCI) && (r->cr & CR_LVBIE)) { event =3D 1; level =3D 1; @@ -275,69 +273,67 @@ static void update_sr (AC97LinkState *s, AC97BusMaste= rRegs *r, uint32_t new_sr) =20 r->sr =3D new_sr; =20 - dolog ("IOC%d LVB%d sr=3D%#x event=3D%d level=3D%d\n", - r->sr & SR_BCIS, r->sr & SR_LVBCI, - r->sr, - event, level); + dolog("IOC%d LVB%d sr=3D0x%x event=3D%d level=3D%d\n", + r->sr & SR_BCIS, r->sr & SR_LVBCI, r->sr, event, level); =20 - if (!event) + if (!event) { return; + } =20 if (level) { s->glob_sta |=3D masks[r - s->bm_regs]; - dolog ("set irq level=3D1\n"); + dolog("set irq level=3D1\n"); pci_irq_assert(&s->dev); - } - else { + } else { s->glob_sta &=3D ~masks[r - s->bm_regs]; - dolog ("set irq level=3D0\n"); + dolog("set irq level=3D0\n"); pci_irq_deassert(&s->dev); } } =20 -static void voice_set_active (AC97LinkState *s, int bm_index, int on) +static void voice_set_active(AC97LinkState *s, int bm_index, int on) { switch (bm_index) { case PI_INDEX: - AUD_set_active_in (s->voice_pi, on); + AUD_set_active_in(s->voice_pi, on); break; =20 case PO_INDEX: - AUD_set_active_out (s->voice_po, on); + AUD_set_active_out(s->voice_po, on); break; =20 case MC_INDEX: - AUD_set_active_in (s->voice_mc, on); + AUD_set_active_in(s->voice_mc, on); break; =20 default: - AUD_log ("ac97", "invalid bm_index(%d) in voice_set_active", bm_in= dex); + AUD_log("ac97", "invalid bm_index(%d) in voice_set_active", bm_ind= ex); break; } } =20 -static void reset_bm_regs (AC97LinkState *s, AC97BusMasterRegs *r) +static void reset_bm_regs(AC97LinkState *s, AC97BusMasterRegs *r) { - dolog ("reset_bm_regs\n"); + dolog("reset_bm_regs\n"); r->bdbar =3D 0; r->civ =3D 0; r->lvi =3D 0; /** todo do we need to do that? */ - update_sr (s, r, SR_DCH); + update_sr(s, r, SR_DCH); r->picb =3D 0; r->piv =3D 0; r->cr =3D r->cr & CR_DONT_CLEAR_MASK; r->bd_valid =3D 0; =20 - voice_set_active (s, r - s->bm_regs, 0); - memset (s->silence, 0, sizeof (s->silence)); + voice_set_active(s, r - s->bm_regs, 0); + memset(s->silence, 0, sizeof(s->silence)); } =20 -static void mixer_store (AC97LinkState *s, uint32_t i, uint16_t v) +static void mixer_store(AC97LinkState *s, uint32_t i, uint16_t v) { - if (i + 2 > sizeof (s->mixer_data)) { - dolog ("mixer_store: index %d out of bounds %zd\n", - i, sizeof (s->mixer_data)); + if (i + 2 > sizeof(s->mixer_data)) { + dolog("mixer_store: index %d out of bounds %zd\n", + i, sizeof(s->mixer_data)); return; } =20 @@ -345,22 +341,21 @@ static void mixer_store (AC97LinkState *s, uint32_t i= , uint16_t v) s->mixer_data[i + 1] =3D v >> 8; } =20 -static uint16_t mixer_load (AC97LinkState *s, uint32_t i) +static uint16_t mixer_load(AC97LinkState *s, uint32_t i) { uint16_t val =3D 0xffff; =20 - if (i + 2 > sizeof (s->mixer_data)) { - dolog ("mixer_load: index %d out of bounds %zd\n", - i, sizeof (s->mixer_data)); - } - else { + if (i + 2 > sizeof(s->mixer_data)) { + dolog("mixer_load: index %d out of bounds %zd\n", + i, sizeof(s->mixer_data)); + } else { val =3D s->mixer_data[i + 0] | (s->mixer_data[i + 1] << 8); } =20 return val; } =20 -static void open_voice (AC97LinkState *s, int index, int freq) +static void open_voice(AC97LinkState *s, int index, int freq) { struct audsettings as; =20 @@ -373,7 +368,7 @@ static void open_voice (AC97LinkState *s, int index, in= t freq) s->invalid_freq[index] =3D 0; switch (index) { case PI_INDEX: - s->voice_pi =3D AUD_open_in ( + s->voice_pi =3D AUD_open_in( &s->card, s->voice_pi, "ac97.pi", @@ -384,7 +379,7 @@ static void open_voice (AC97LinkState *s, int index, in= t freq) break; =20 case PO_INDEX: - s->voice_po =3D AUD_open_out ( + s->voice_po =3D AUD_open_out( &s->card, s->voice_po, "ac97.po", @@ -395,7 +390,7 @@ static void open_voice (AC97LinkState *s, int index, in= t freq) break; =20 case MC_INDEX: - s->voice_mc =3D AUD_open_in ( + s->voice_mc =3D AUD_open_in( &s->card, s->voice_mc, "ac97.mc", @@ -405,47 +400,46 @@ static void open_voice (AC97LinkState *s, int index, = int freq) ); break; } - } - else { + } else { s->invalid_freq[index] =3D freq; switch (index) { case PI_INDEX: - AUD_close_in (&s->card, s->voice_pi); + AUD_close_in(&s->card, s->voice_pi); s->voice_pi =3D NULL; break; =20 case PO_INDEX: - AUD_close_out (&s->card, s->voice_po); + AUD_close_out(&s->card, s->voice_po); s->voice_po =3D NULL; break; =20 case MC_INDEX: - AUD_close_in (&s->card, s->voice_mc); + AUD_close_in(&s->card, s->voice_mc); s->voice_mc =3D NULL; break; } } } =20 -static void reset_voices (AC97LinkState *s, uint8_t active[LAST_INDEX]) +static void reset_voices(AC97LinkState *s, uint8_t active[LAST_INDEX]) { uint16_t freq; =20 - freq =3D mixer_load (s, AC97_PCM_LR_ADC_Rate); - open_voice (s, PI_INDEX, freq); - AUD_set_active_in (s->voice_pi, active[PI_INDEX]); + freq =3D mixer_load(s, AC97_PCM_LR_ADC_Rate); + open_voice(s, PI_INDEX, freq); + AUD_set_active_in(s->voice_pi, active[PI_INDEX]); =20 - freq =3D mixer_load (s, AC97_PCM_Front_DAC_Rate); - open_voice (s, PO_INDEX, freq); - AUD_set_active_out (s->voice_po, active[PO_INDEX]); + freq =3D mixer_load(s, AC97_PCM_Front_DAC_Rate); + open_voice(s, PO_INDEX, freq); + AUD_set_active_out(s->voice_po, active[PO_INDEX]); =20 - freq =3D mixer_load (s, AC97_MIC_ADC_Rate); - open_voice (s, MC_INDEX, freq); - AUD_set_active_in (s->voice_mc, active[MC_INDEX]); + freq =3D mixer_load(s, AC97_MIC_ADC_Rate); + open_voice(s, MC_INDEX, freq); + AUD_set_active_in(s->voice_mc, active[MC_INDEX]); } =20 -static void get_volume (uint16_t vol, uint16_t mask, int inverse, - int *mute, uint8_t *lvol, uint8_t *rvol) +static void get_volume(uint16_t vol, uint16_t mask, int inverse, + int *mute, uint8_t *lvol, uint8_t *rvol) { *mute =3D (vol >> MUTE_SHIFT) & 1; *rvol =3D (255 * (vol & mask)) / mask; @@ -457,120 +451,120 @@ static void get_volume (uint16_t vol, uint16_t mask= , int inverse, } } =20 -static void update_combined_volume_out (AC97LinkState *s) +static void update_combined_volume_out(AC97LinkState *s) { uint8_t lvol, rvol, plvol, prvol; int mute, pmute; =20 - get_volume (mixer_load (s, AC97_Master_Volume_Mute), 0x3f, 1, - &mute, &lvol, &rvol); - get_volume (mixer_load (s, AC97_PCM_Out_Volume_Mute), 0x1f, 1, - &pmute, &plvol, &prvol); + get_volume(mixer_load(s, AC97_Master_Volume_Mute), 0x3f, 1, + &mute, &lvol, &rvol); + get_volume(mixer_load(s, AC97_PCM_Out_Volume_Mute), 0x1f, 1, + &pmute, &plvol, &prvol); =20 mute =3D mute | pmute; lvol =3D (lvol * plvol) / 255; rvol =3D (rvol * prvol) / 255; =20 - AUD_set_volume_out (s->voice_po, mute, lvol, rvol); + AUD_set_volume_out(s->voice_po, mute, lvol, rvol); } =20 -static void update_volume_in (AC97LinkState *s) +static void update_volume_in(AC97LinkState *s) { uint8_t lvol, rvol; int mute; =20 - get_volume (mixer_load (s, AC97_Record_Gain_Mute), 0x0f, 0, - &mute, &lvol, &rvol); + get_volume(mixer_load(s, AC97_Record_Gain_Mute), 0x0f, 0, + &mute, &lvol, &rvol); =20 - AUD_set_volume_in (s->voice_pi, mute, lvol, rvol); + AUD_set_volume_in(s->voice_pi, mute, lvol, rvol); } =20 -static void set_volume (AC97LinkState *s, int index, uint32_t val) +static void set_volume(AC97LinkState *s, int index, uint32_t val) { switch (index) { case AC97_Master_Volume_Mute: val &=3D 0xbf3f; - mixer_store (s, index, val); - update_combined_volume_out (s); + mixer_store(s, index, val); + update_combined_volume_out(s); break; case AC97_PCM_Out_Volume_Mute: val &=3D 0x9f1f; - mixer_store (s, index, val); - update_combined_volume_out (s); + mixer_store(s, index, val); + update_combined_volume_out(s); break; case AC97_Record_Gain_Mute: val &=3D 0x8f0f; - mixer_store (s, index, val); - update_volume_in (s); + mixer_store(s, index, val); + update_volume_in(s); break; } } =20 -static void record_select (AC97LinkState *s, uint32_t val) +static void record_select(AC97LinkState *s, uint32_t val) { uint8_t rs =3D val & REC_MASK; uint8_t ls =3D (val >> 8) & REC_MASK; - mixer_store (s, AC97_Record_Select, rs | (ls << 8)); + mixer_store(s, AC97_Record_Select, rs | (ls << 8)); } =20 -static void mixer_reset (AC97LinkState *s) +static void mixer_reset(AC97LinkState *s) { uint8_t active[LAST_INDEX]; =20 - dolog ("mixer_reset\n"); - memset (s->mixer_data, 0, sizeof (s->mixer_data)); - memset (active, 0, sizeof (active)); - mixer_store (s, AC97_Reset (s, AC97_CD_Volume_Mute , 0x00= 00); - mixer_store (s, AC97_Video_Volume_Mute , 0x0000); - mixer_store (s, AC97_Aux_Volume_Mute , 0x0000); - mixer_store (s, AC97_Record_Gain_Mic_Mute , 0x0000); - mixer_store (s, AC97_General_Purpose , 0x0000); - mixer_store (s, AC97_3D_Control , 0x0000); - mixer_store (s, AC97_Powerdown_Ctrl_Stat , 0x000f); + dolog("mixer_reset\n"); + memset(s->mixer_data, 0, sizeof(s->mixer_data)); + memset(active, 0, sizeof(active)); + mixer_store(s, AC97_Reset, 0x0000); /* 6940 */ + mixer_store(s, AC97_Headphone_Volume_Mute, 0x0000); + mixer_store(s, AC97_Master_Volume_Mono_Mute, 0x0000); + mixer_store(s, AC97_Master_Tone_RL, 0x0000); + mixer_store(s, AC97_PC_BEEP_Volume_Mute, 0x0000); + mixer_store(s, AC97_Phone_Volume_Mute, 0x0000); + mixer_store(s, AC97_Mic_Volume_Mute, 0x0000); + mixer_store(s, AC97_Line_In_Volume_Mute, 0x0000); + mixer_store(s, AC97_CD_Volume_Mute, 0x0000); + mixer_store(s, AC97_Video_Volume_Mute, 0x0000); + mixer_store(s, AC97_Aux_Volume_Mute, 0x0000); + mixer_store(s, AC97_Record_Gain_Mic_Mute, 0x0000); + mixer_store(s, AC97_General_Purpose, 0x0000); + mixer_store(s, AC97_3D_Control, 0x0000); + mixer_store(s, AC97_Powerdown_Ctrl_Stat, 0x000f); =20 /* * Sigmatel 9700 (STAC9700) */ - mixer_store (s, AC97_Vendor_ID1 , 0x8384); - mixer_store (s, AC97_Vendor_ID2 , 0x7600); /* 7608 */ + mixer_store(s, AC97_Vendor_ID1, 0x8384); + mixer_store(s, AC97_Vendor_ID2, 0x7600); /* 7608 */ =20 - mixer_store (s, AC97_Extended_Audio_ID , 0x0809); - mixer_store (s, AC97_Extended_Audio_Ctrl_Stat, 0x0009); - mixer_store (s, AC97_PCM_Front_DAC_Rate , 0xbb80); - mixer_store (s, AC97_PCM_Surround_DAC_Rate , 0xbb80); - mixer_store (s, AC97_PCM_LFE_DAC_Rate , 0xbb80); - mixer_store (s, AC97_PCM_LR_ADC_Rate , 0xbb80); - mixer_store (s, AC97_MIC_ADC_Rate , 0xbb80); + mixer_store(s, AC97_Extended_Audio_ID, 0x0809); + mixer_store(s, AC97_Extended_Audio_Ctrl_Stat, 0x0009); + mixer_store(s, AC97_PCM_Front_DAC_Rate, 0xbb80); + mixer_store(s, AC97_PCM_Surround_DAC_Rate, 0xbb80); + mixer_store(s, AC97_PCM_LFE_DAC_Rate, 0xbb80); + mixer_store(s, AC97_PCM_LR_ADC_Rate, 0xbb80); + mixer_store(s, AC97_MIC_ADC_Rate, 0xbb80); =20 - record_select (s, 0); - set_volume (s, AC97_Master_Volume_Mute, 0x8000); - set_volume (s, AC97_PCM_Out_Volume_Mute, 0x8808); - set_volume (s, AC97_Record_Gain_Mute, 0x8808); + record_select(s, 0); + set_volume(s, AC97_Master_Volume_Mute, 0x8000); + set_volume(s, AC97_PCM_Out_Volume_Mute, 0x8808); + set_volume(s, AC97_Record_Gain_Mute, 0x8808); =20 - reset_voices (s, active); + reset_voices(s, active); } =20 /** * Native audio mixer * I/O Reads */ -static uint32_t nam_readb (void *opaque, uint32_t addr) +static uint32_t nam_readb(void *opaque, uint32_t addr) { AC97LinkState *s =3D opaque; - dolog ("U nam readb %#x\n", addr); + dolog("U nam readb 0x%x\n", addr); s->cas =3D 0; return ~0U; } =20 -static uint32_t nam_readw (void *opaque, uint32_t addr) +static uint32_t nam_readw(void *opaque, uint32_t addr) { AC97LinkState *s =3D opaque; uint32_t index =3D addr; @@ -578,10 +572,10 @@ static uint32_t nam_readw (void *opaque, uint32_t add= r) return mixer_load(s, index); } =20 -static uint32_t nam_readl (void *opaque, uint32_t addr) +static uint32_t nam_readl(void *opaque, uint32_t addr) { AC97LinkState *s =3D opaque; - dolog ("U nam readl %#x\n", addr); + dolog("U nam readl 0x%x\n", addr); s->cas =3D 0; return ~0U; } @@ -590,89 +584,84 @@ static uint32_t nam_readl (void *opaque, uint32_t add= r) * Native audio mixer * I/O Writes */ -static void nam_writeb (void *opaque, uint32_t addr, uint32_t val) +static void nam_writeb(void *opaque, uint32_t addr, uint32_t val) { AC97LinkState *s =3D opaque; - dolog ("U nam writeb %#x <- %#x\n", addr, val); + dolog("U nam writeb 0x%x <- 0x%x\n", addr, val); s->cas =3D 0; } =20 -static void nam_writew (void *opaque, uint32_t addr, uint32_t val) +static void nam_writew(void *opaque, uint32_t addr, uint32_t val) { AC97LinkState *s =3D opaque; uint32_t index =3D addr; s->cas =3D 0; switch (index) { case AC97_Reset: - mixer_reset (s); + mixer_reset(s); break; case AC97_Powerdown_Ctrl_Stat: val &=3D ~0x800f; - val |=3D mixer_load (s, index) & 0xf; - mixer_store (s, index, val); + val |=3D mixer_load(s, index) & 0xf; + mixer_store(s, index, val); break; case AC97_PCM_Out_Volume_Mute: case AC97_Master_Volume_Mute: case AC97_Record_Gain_Mute: - set_volume (s, index, val); + set_volume(s, index, val); break; case AC97_Record_Select: - record_select (s, val); + record_select(s, val); break; case AC97_Vendor_ID1: case AC97_Vendor_ID2: - dolog ("Attempt to write vendor ID to %#x\n", val); + dolog("Attempt to write vendor ID to 0x%x\n", val); break; case AC97_Extended_Audio_ID: - dolog ("Attempt to write extended audio ID to %#x\n", val); + dolog("Attempt to write extended audio ID to 0x%x\n", val); break; case AC97_Extended_Audio_Ctrl_Stat: if (!(val & EACS_VRA)) { - mixer_store (s, AC97_PCM_Front_DAC_Rate, 0xbb80); - mixer_store (s, AC97_PCM_LR_ADC_Rate, 0xbb80); - open_voice (s, PI_INDEX, 48000); - open_voice (s, PO_INDEX, 48000); + mixer_store(s, AC97_PCM_Front_DAC_Rate, 0xbb80); + mixer_store(s, AC97_PCM_LR_ADC_Rate, 0xbb80); + open_voice(s, PI_INDEX, 48000); + open_voice(s, PO_INDEX, 48000); } if (!(val & EACS_VRM)) { - mixer_store (s, AC97_MIC_ADC_Rate, 0xbb80); - open_voice (s, MC_INDEX, 48000); + mixer_store(s, AC97_MIC_ADC_Rate, 0xbb80); + open_voice(s, MC_INDEX, 48000); } - dolog ("Setting extended audio control to %#x\n", val); - mixer_store (s, AC97_Extended_Audio_Ctrl_Stat, val); + dolog("Setting extended audio control to 0x%x\n", val); + mixer_store(s, AC97_Extended_Audio_Ctrl_Stat, val); break; case AC97_PCM_Front_DAC_Rate: - if (mixer_load (s, AC97_Extended_Audio_Ctrl_Stat) & EACS_VRA) { - mixer_store (s, index, val); - dolog ("Set front DAC rate to %d\n", val); - open_voice (s, PO_INDEX, val); - } - else { - dolog ("Attempt to set front DAC rate to %d, " - "but VRA is not set\n", - val); + if (mixer_load(s, AC97_Extended_Audio_Ctrl_Stat) & EACS_VRA) { + mixer_store(s, index, val); + dolog("Set front DAC rate to %d\n", val); + open_voice(s, PO_INDEX, val); + } else { + dolog("Attempt to set front DAC rate to %d, but VRA is not set= \n", + val); } break; case AC97_MIC_ADC_Rate: - if (mixer_load (s, AC97_Extended_Audio_Ctrl_Stat) & EACS_VRM) { - mixer_store (s, index, val); - dolog ("Set MIC ADC rate to %d\n", val); - open_voice (s, MC_INDEX, val); - } - else { - dolog ("Attempt to set MIC ADC rate to %d, " - "but VRM is not set\n", - val); + if (mixer_load(s, AC97_Extended_Audio_Ctrl_Stat) & EACS_VRM) { + mixer_store(s, index, val); + dolog("Set MIC ADC rate to %d\n", val); + open_voice(s, MC_INDEX, val); + } else { + dolog("Attempt to set MIC ADC rate to %d, but VRM is not set\n= ", + val); } break; case AC97_PCM_LR_ADC_Rate: - if (mixer_load (s, AC97_Extended_Audio_Ctrl_Stat) & EACS_VRA) { - mixer_store (s, index, val); - dolog ("Set front LR ADC rate to %d\n", val); - open_voice (s, PI_INDEX, val); - } - else { - dolog ("Attempt to set LR ADC rate to %d, but VRA is not set\n= ", - val); + if (mixer_load(s, AC97_Extended_Audio_Ctrl_Stat) & EACS_VRA) { + mixer_store(s, index, val); + dolog("Set front LR ADC rate to %d\n", val); + open_voice(s, PI_INDEX, val); + } else { + dolog("Attempt to set LR ADC rate to %d, but VRA is not set\n", + val); } break; case AC97_Headphone_Volume_Mute: @@ -693,16 +682,16 @@ static void nam_writew (void *opaque, uint32_t addr, = uint32_t val) /* None of the features in these regs are emulated, so they are RO= */ break; default: - dolog ("U nam writew %#x <- %#x\n", addr, val); - mixer_store (s, index, val); + dolog("U nam writew 0x%x <- 0x%x\n", addr, val); + mixer_store(s, index, val); break; } } =20 -static void nam_writel (void *opaque, uint32_t addr, uint32_t val) +static void nam_writel(void *opaque, uint32_t addr, uint32_t val) { AC97LinkState *s =3D opaque; - dolog ("U nam writel %#x <- %#x\n", addr, val); + dolog("U nam writel 0x%x <- 0x%x\n", addr, val); s->cas =3D 0; } =20 @@ -710,7 +699,7 @@ static void nam_writel (void *opaque, uint32_t addr, ui= nt32_t val) * Native audio bus master * I/O Reads */ -static uint32_t nabm_readb (void *opaque, uint32_t addr) +static uint32_t nabm_readb(void *opaque, uint32_t addr) { AC97LinkState *s =3D opaque; AC97BusMasterRegs *r =3D NULL; @@ -719,53 +708,53 @@ static uint32_t nabm_readb (void *opaque, uint32_t ad= dr) =20 switch (index) { case CAS: - dolog ("CAS %d\n", s->cas); + dolog("CAS %d\n", s->cas); val =3D s->cas; s->cas =3D 1; break; case PI_CIV: case PO_CIV: case MC_CIV: - r =3D &s->bm_regs[GET_BM (index)]; + r =3D &s->bm_regs[GET_BM(index)]; val =3D r->civ; - dolog ("CIV[%d] -> %#x\n", GET_BM (index), val); + dolog("CIV[%d] -> 0x%x\n", GET_BM(index), val); break; case PI_LVI: case PO_LVI: case MC_LVI: - r =3D &s->bm_regs[GET_BM (index)]; + r =3D &s->bm_regs[GET_BM(index)]; val =3D r->lvi; - dolog ("LVI[%d] -> %#x\n", GET_BM (index), val); + dolog("LVI[%d] -> 0x%x\n", GET_BM(index), val); break; case PI_PIV: case PO_PIV: case MC_PIV: - r =3D &s->bm_regs[GET_BM (index)]; + r =3D &s->bm_regs[GET_BM(index)]; val =3D r->piv; - dolog ("PIV[%d] -> %#x\n", GET_BM (index), val); + dolog("PIV[%d] -> 0x%x\n", GET_BM(index), val); break; case PI_CR: case PO_CR: case MC_CR: - r =3D &s->bm_regs[GET_BM (index)]; + r =3D &s->bm_regs[GET_BM(index)]; val =3D r->cr; - dolog ("CR[%d] -> %#x\n", GET_BM (index), val); + dolog("CR[%d] -> 0x%x\n", GET_BM(index), val); break; case PI_SR: case PO_SR: case MC_SR: - r =3D &s->bm_regs[GET_BM (index)]; + r =3D &s->bm_regs[GET_BM(index)]; val =3D r->sr & 0xff; - dolog ("SRb[%d] -> %#x\n", GET_BM (index), val); + dolog("SRb[%d] -> 0x%x\n", GET_BM(index), val); break; default: - dolog ("U nabm readb %#x -> %#x\n", addr, val); + dolog("U nabm readb 0x%x -> 0x%x\n", addr, val); break; } return val; } =20 -static uint32_t nabm_readw (void *opaque, uint32_t addr) +static uint32_t nabm_readw(void *opaque, uint32_t addr) { AC97LinkState *s =3D opaque; AC97BusMasterRegs *r =3D NULL; @@ -776,25 +765,25 @@ static uint32_t nabm_readw (void *opaque, uint32_t ad= dr) case PI_SR: case PO_SR: case MC_SR: - r =3D &s->bm_regs[GET_BM (index)]; + r =3D &s->bm_regs[GET_BM(index)]; val =3D r->sr; - dolog ("SR[%d] -> %#x\n", GET_BM (index), val); + dolog("SR[%d] -> 0x%x\n", GET_BM(index), val); break; case PI_PICB: case PO_PICB: case MC_PICB: - r =3D &s->bm_regs[GET_BM (index)]; + r =3D &s->bm_regs[GET_BM(index)]; val =3D r->picb; - dolog ("PICB[%d] -> %#x\n", GET_BM (index), val); + dolog("PICB[%d] -> 0x%x\n", GET_BM(index), val); break; default: - dolog ("U nabm readw %#x -> %#x\n", addr, val); + dolog("U nabm readw 0x%x -> 0x%x\n", addr, val); break; } return val; } =20 -static uint32_t nabm_readl (void *opaque, uint32_t addr) +static uint32_t nabm_readl(void *opaque, uint32_t addr) { AC97LinkState *s =3D opaque; AC97BusMasterRegs *r =3D NULL; @@ -805,36 +794,36 @@ static uint32_t nabm_readl (void *opaque, uint32_t ad= dr) case PI_BDBAR: case PO_BDBAR: case MC_BDBAR: - r =3D &s->bm_regs[GET_BM (index)]; + r =3D &s->bm_regs[GET_BM(index)]; val =3D r->bdbar; - dolog ("BMADDR[%d] -> %#x\n", GET_BM (index), val); + dolog("BMADDR[%d] -> 0x%x\n", GET_BM(index), val); break; case PI_CIV: case PO_CIV: case MC_CIV: - r =3D &s->bm_regs[GET_BM (index)]; + r =3D &s->bm_regs[GET_BM(index)]; val =3D r->civ | (r->lvi << 8) | (r->sr << 16); - dolog ("CIV LVI SR[%d] -> %#x, %#x, %#x\n", GET_BM (index), + dolog("CIV LVI SR[%d] -> 0x%x, 0x%x, 0x%x\n", GET_BM(index), r->civ, r->lvi, r->sr); break; case PI_PICB: case PO_PICB: case MC_PICB: - r =3D &s->bm_regs[GET_BM (index)]; + r =3D &s->bm_regs[GET_BM(index)]; val =3D r->picb | (r->piv << 16) | (r->cr << 24); - dolog ("PICB PIV CR[%d] -> %#x %#x %#x %#x\n", GET_BM (index), + dolog("PICB PIV CR[%d] -> 0x%x 0x%x 0x%x 0x%x\n", GET_BM(index), val, r->picb, r->piv, r->cr); break; case GLOB_CNT: val =3D s->glob_cnt; - dolog ("glob_cnt -> %#x\n", val); + dolog("glob_cnt -> 0x%x\n", val); break; case GLOB_STA: val =3D s->glob_sta | GS_S0CR; - dolog ("glob_sta -> %#x\n", val); + dolog("glob_sta -> 0x%x\n", val); break; default: - dolog ("U nabm readl %#x -> %#x\n", addr, val); + dolog("U nabm readl 0x%x -> 0x%x\n", addr, val); break; } return val; @@ -844,7 +833,7 @@ static uint32_t nabm_readl (void *opaque, uint32_t addr) * Native audio bus master * I/O Writes */ -static void nabm_writeb (void *opaque, uint32_t addr, uint32_t val) +static void nabm_writeb(void *opaque, uint32_t addr, uint32_t val) { AC97LinkState *s =3D opaque; AC97BusMasterRegs *r =3D NULL; @@ -853,54 +842,52 @@ static void nabm_writeb (void *opaque, uint32_t addr,= uint32_t val) case PI_LVI: case PO_LVI: case MC_LVI: - r =3D &s->bm_regs[GET_BM (index)]; + r =3D &s->bm_regs[GET_BM(index)]; if ((r->cr & CR_RPBM) && (r->sr & SR_DCH)) { r->sr &=3D ~(SR_DCH | SR_CELV); r->civ =3D r->piv; r->piv =3D (r->piv + 1) % 32; - fetch_bd (s, r); + fetch_bd(s, r); } r->lvi =3D val % 32; - dolog ("LVI[%d] <- %#x\n", GET_BM (index), val); + dolog("LVI[%d] <- 0x%x\n", GET_BM(index), val); break; case PI_CR: case PO_CR: case MC_CR: - r =3D &s->bm_regs[GET_BM (index)]; + r =3D &s->bm_regs[GET_BM(index)]; if (val & CR_RR) { - reset_bm_regs (s, r); - } - else { + reset_bm_regs(s, r); + } else { r->cr =3D val & CR_VALID_MASK; if (!(r->cr & CR_RPBM)) { - voice_set_active (s, r - s->bm_regs, 0); + voice_set_active(s, r - s->bm_regs, 0); r %#x)\n", GET_BM (index), val, r->cr); + dolog("CR[%d] <- 0x%x (cr 0x%x)\n", GET_BM(index), val, r->cr); break; case PI_SR: case PO_SR: case MC_SR: - r =3D &s->bm_regs[GET_BM (index)]; + r =3D &s->bm_regs[GET_BM(index)]; r->sr |=3D val & ~(SR_RO_MASK | SR_WCLEAR_MASK); - update_sr (s, r, r->sr & ~(val & SR_WCLEAR_MASK)); - dolog ("SR[%d] <- %#x (sr %#x)\n", GET_BM (index), val, r->sr); + update_sr(s, r, r->sr & ~(val & SR_WCLEAR_MASK)); + dolog("SR[%d] <- 0x%x (sr 0x%x)\n", GET_BM(index), val, r->sr); break; default: - dolog ("U nabm writeb %#x <- %#x\n", addr, val); + dolog("U nabm writeb 0x%x <- 0x%x\n", addr, val); break; } } =20 -static void nabm_writew (void *opaque, uint32_t addr, uint32_t val) +static void nabm_writew(void *opaque, uint32_t addr, uint32_t val) { AC97LinkState *s =3D opaque; AC97BusMasterRegs *r =3D NULL; @@ -909,18 +896,18 @@ static void nabm_writew (void *opaque, uint32_t addr,= uint32_t val) case PI_SR: case PO_SR: case MC_SR: - r =3D &s->bm_regs[GET_BM (index)]; + r =3D &s->bm_regs[GET_BM(index)]; r->sr |=3D val & ~(SR_RO_MASK | SR_WCLEAR_MASK); - update_sr (s, r, r->sr & ~(val & SR_WCLEAR_MASK)); - dolog ("SR[%d] <- %#x (sr %#x)\n", GET_BM (index), val, r->sr); + update_sr(s, r, r->sr & ~(val & SR_WCLEAR_MASK)); + dolog("SR[%d] <- 0x%x (sr 0x%x)\n", GET_BM(index), val, r->sr); break; default: - dolog ("U nabm writew %#x <- %#x\n", addr, val); + dolog("U nabm writew 0x%x <- 0x%x\n", addr, val); break; } } =20 -static void nabm_writel (void *opaque, uint32_t addr, uint32_t val) +static void nabm_writel(void *opaque, uint32_t addr, uint32_t val) { AC97LinkState *s =3D opaque; AC97BusMasterRegs *r =3D NULL; @@ -929,40 +916,42 @@ static void nabm_writel (void *opaque, uint32_t addr,= uint32_t val) case PI_BDBAR: case PO_BDBAR: case MC_BDBAR: - r =3D &s->bm_regs[GET_BM (index)]; + r =3D &s->bm_regs[GET_BM(index)]; r->bdbar =3D val & ~3; - dolog ("BDBAR[%d] <- %#x (bdbar %#x)\n", - GET_BM (index), val, r->bdbar); + dolog("BDBAR[%d] <- 0x%x (bdbar 0x%x)\n", GET_BM(index), val, r->b= dbar); break; case GLOB_CNT: - if (val & GC_WR) - warm_reset (s); - if (val & GC_CR) - cold_reset (s); - if (!(val & (GC_WR | GC_CR))) + if (val & GC_WR) { + warm_reset(s); + } + if (val & GC_CR) { + cold_reset(s); + } + if (!(val & (GC_WR | GC_CR))) { s->glob_cnt =3D val & GC_VALID_MASK; - dolog ("glob_cnt <- %#x (glob_cnt %#x)\n", val, s->glob_cnt); + } + dolog("glob_cnt <- 0x%x (glob_cnt 0x%x)\n", val, s->glob_cnt); break; case GLOB_STA: s->glob_sta &=3D ~(val & GS_WCLEAR_MASK); s->glob_sta |=3D (val & ~(GS_WCLEAR_MASK | GS_RO_MASK)) & GS_VALID= _MASK; - dolog ("glob_sta <- %#x (glob_sta %#x)\n", val, s->glob_sta); + dolog("glob_sta <- 0x%x (glob_sta 0x%x)\n", val, s->glob_sta); break; default: - dolog ("U nabm writel %#x <- %#x\n", addr, val); + dolog("U nabm writel 0x%x <- 0x%x\n", addr, val); break; } } =20 -static int write_audio (AC97LinkState *s, AC97BusMasterRegs *r, - int max, int *stop) +static int write_audio(AC97LinkState *s, AC97BusMasterRegs *r, + int max, int *stop) { uint8_t tmpbuf[4096]; uint32_t addr =3D r->bd.addr; uint32_t temp =3D r->picb << 1; uint32_t written =3D 0; int to_copy =3D 0; - temp =3D MIN (temp, max); + temp =3D MIN(temp, max); =20 if (!temp) { *stop =3D 1; @@ -971,11 +960,11 @@ static int write_audio (AC97LinkState *s, AC97BusMast= erRegs *r, =20 while (temp) { int copied; - to_copy =3D MIN (temp, sizeof (tmpbuf)); - pci_dma_read (&s->dev, addr, tmpbuf, to_copy); - copied =3D AUD_write (s->voice_po, tmpbuf, to_copy); - dolog ("write_audio max=3D%x to_copy=3D%x copied=3D%x\n", - max, to_copy, copied); + to_copy =3D MIN(temp, sizeof(tmpbuf)); + pci_dma_read(&s->dev, addr, tmpbuf, to_copy); + copied =3D AUD_write(s->voice_po, tmpbuf, to_copy); + dolog("write_audio max=3D%x to_copy=3D%x copied=3D%x\n", + max, to_copy, copied); if (!copied) { *stop =3D 1; break; @@ -987,11 +976,10 @@ static int write_audio (AC97LinkState *s, AC97BusMast= erRegs *r, =20 if (!temp) { if (to_copy < 4) { - dolog ("whoops\n"); + dolog("whoops\n"); s->last_samp =3D 0; - } - else { - s->last_samp =3D *(uint32_t *) &tmpbuf[to_copy - 4]; + } else { + s->last_samp =3D *(uint32_t *)&tmpbuf[to_copy - 4]; } } =20 @@ -999,37 +987,37 @@ static int write_audio (AC97LinkState *s, AC97BusMast= erRegs *r, return written; } =20 -static void write_bup (AC97LinkState *s, int elapsed) +static void write_bup(AC97LinkState *s, int elapsed) { - dolog ("write_bup\n"); + dolog("write_bup\n"); if (!(s->bup_flag & BUP_SET)) { if (s->bup_flag & BUP_LAST) { int i; uint8_t *p =3D s->silence; - for (i =3D 0; i < sizeof (s->silence) / 4; i++, p +=3D 4) { + for (i =3D 0; i < sizeof(s->silence) / 4; i++, p +=3D 4) { *(uint32_t *) p =3D s->last_samp; } - } - else { - memset (s->silence, 0, sizeof (s->silence)); + } else { + memset(s->silence, 0, sizeof(s->silence)); } s->bup_flag |=3D BUP_SET; } =20 while (elapsed) { - int temp =3D MIN (elapsed, sizeof (s->silence)); + int temp =3D MIN(elapsed, sizeof(s->silence)); while (temp) { - int copied =3D AUD_write (s->voice_po, s->silence, temp); - if (!copied) + int copied =3D AUD_write(s->voice_po, s->silence, temp); + if (!copied) { return; + } temp -=3D copied; elapsed -=3D copied; } } } =20 -static int read_audio (AC97LinkState *s, AC97BusMasterRegs *r, - int max, int *stop) +static int read_audio(AC97LinkState *s, AC97BusMasterRegs *r, + int max, int *stop) { uint8_t tmpbuf[4096]; uint32_t addr =3D r->bd.addr; @@ -1038,7 +1026,7 @@ static int read_audio (AC97LinkState *s, AC97BusMaste= rRegs *r, int to_copy =3D 0; SWVoiceIn *voice =3D (r - s->bm_regs) =3D=3D MC_INDEX ? s->voice_mc : = s->voice_pi; =20 - temp =3D MIN (temp, max); + temp =3D MIN(temp, max); =20 if (!temp) { *stop =3D 1; @@ -1047,13 +1035,13 @@ static int read_audio (AC97LinkState *s, AC97BusMas= terRegs *r, =20 while (temp) { int acquired; - to_copy =3D MIN (temp, sizeof (tmpbuf)); - acquired =3D AUD_read (voice, tmpbuf, to_copy); + to_copy =3D MIN(temp, sizeof(tmpbuf)); + acquired =3D AUD_read(voice, tmpbuf, to_copy); if (!acquired) { *stop =3D 1; break; } - pci_dma_write (&s->dev, addr, tmpbuf, acquired); + pci_dma_write(&s->dev, addr, tmpbuf, acquired); temp -=3D acquired; addr +=3D acquired; nread +=3D acquired; @@ -1063,14 +1051,14 @@ static int read_audio (AC97LinkState *s, AC97BusMas= terRegs *r, return nread; } =20 -static void transfer_audio (AC97LinkState *s, int index, int elapsed) +static void transfer_audio(AC97LinkState *s, int index, int elapsed) { AC97BusMasterRegs *r =3D &s->bm_regs[index]; int stop =3D 0; =20 if (s->invalid_freq[index]) { - AUD_log ("ac97", "attempt to use voice %d with invalid frequency %= d\n", - index, s->invalid_freq[index]); + AUD_log("ac97", "attempt to use voice %d with invalid frequency %d= \n", + index, s->invalid_freq[index]); return; } =20 @@ -1078,7 +1066,7 @@ static void transfer_audio (AC97LinkState *s, int ind= ex, int elapsed) if (r->cr & CR_RPBM) { switch (index) { case PO_INDEX: - write_bup (s, elapsed); + write_bup(s, elapsed); break; } } @@ -1089,13 +1077,13 @@ static void transfer_audio (AC97LinkState *s, int i= ndex, int elapsed) int temp; =20 if (!r->bd_valid) { - dolog ("invalid bd\n"); - fetch_bd (s, r); + dolog("invalid bd\n"); + fetch_bd(s, r); } =20 if (!r->picb) { - dolog ("fresh bd %d is empty %#x %#x\n", - r->civ, r->bd.addr, r->bd.ctl_len); + dolog("fresh bd %d is empty 0x%x 0x%x\n", + r->civ, r->bd.addr, r->bd.ctl_len); if (r->civ =3D=3D r->lvi) { r->sr |=3D SR_DCH; /* CELV? */ s->bup_flag =3D 0; @@ -1104,20 +1092,20 @@ static void transfer_audio (AC97LinkState *s, int i= ndex, int elapsed) r->sr &=3D ~SR_CELV; r->civ =3D r->piv; r->piv =3D (r->piv + 1) % 32; - fetch_bd (s, r); + fetch_bd(s, r); return; } =20 switch (index) { case PO_INDEX: - temp =3D write_audio (s, r, elapsed, &stop); + temp =3D write_audio(s, r, elapsed, &stop); elapsed -=3D temp; r->picb -=3D (temp >> 1); break; =20 case PI_INDEX: case MC_INDEX: - temp =3D read_audio (s, r, elapsed, &stop); + temp =3D read_audio(s, r, elapsed, &stop); elapsed -=3D temp; r->picb -=3D (temp >> 1); break; @@ -1131,36 +1119,35 @@ static void transfer_audio (AC97LinkState *s, int i= ndex, int elapsed) } =20 if (r->civ =3D=3D r->lvi) { - dolog ("Underrun civ (%d) =3D=3D lvi (%d)\n", r->civ, r->l= vi); + dolog("Underrun civ (%d) =3D=3D lvi (%d)\n", r->civ, r->lv= i); =20 new_sr |=3D SR_LVBCI | SR_DCH | SR_CELV; stop =3D 1; s->bup_flag =3D (r->bd.ctl_len & BD_BUP) ? BUP_LAST : 0; - } - else { + } else { r->civ =3D r->piv; r->piv =3D (r->piv + 1) % 32; - fetch_bd (s, r); + fetch_bd(s, r); } =20 - update_sr (s, r, new_sr); + update_sr(s, r, new_sr); } } } =20 -static void pi_callback (void *opaque, int avail) +static void pi_callback(void *opaque, int avail) { - transfer_audio (opaque, PI_INDEX, avail); + transfer_audio(opaque, PI_INDEX, avail); } =20 -static void mc_callback (void *opaque, int avail) +static void mc_callback(void *opaque, int avail) { - transfer_audio (opaque, MC_INDEX, avail); + transfer_audio(opaque, MC_INDEX, avail); } =20 -static void po_callback (void *opaque, int free) +static void po_callback(void *opaque, int free) { - transfer_audio (opaque, PO_INDEX, free); + transfer_audio(opaque, PO_INDEX, free); } =20 static const VMStateDescription vmstate_ac97_bm_regs =3D { @@ -1168,44 +1155,44 @@ static const VMStateDescription vmstate_ac97_bm_reg= s =3D { .version_id =3D 1, .minimum_version_id =3D 1, .fields =3D (VMStateField[]) { - VMSTATE_UINT32 (bdbar, AC97BusMasterRegs), - VMSTATE_UINT8 (civ, AC97BusMasterRegs), - VMSTATE_UINT8 (lvi, AC97BusMasterRegs), - VMSTATE_UINT16 (sr, AC97BusMasterRegs), - VMSTATE_UINT16 (picb, AC97BusMasterRegs), - VMSTATE_UINT8 (piv, AC97BusMasterRegs), - VMSTATE_UINT8 (cr, AC97BusMasterRegs), - VMSTATE_UINT32 (bd_valid, AC97BusMasterRegs), - VMSTATE_UINT32 (bd.addr, AC97BusMasterRegs), - VMSTATE_UINT32 (bd.ctl_len, AC97BusMasterRegs), - VMSTATE_END_OF_LIST () + VMSTATE_UINT32(bdbar, AC97BusMasterRegs), + VMSTATE_UINT8(civ, AC97BusMasterRegs), + VMSTATE_UINT8(lvi, AC97BusMasterRegs), + VMSTATE_UINT16(sr, AC97BusMasterRegs), + VMSTATE_UINT16(picb, AC97BusMasterRegs), + VMSTATE_UINT8(piv, AC97BusMasterRegs), + VMSTATE_UINT8(cr, AC97BusMasterRegs), + VMSTATE_UINT32(bd_valid, AC97BusMasterRegs), + VMSTATE_UINT32(bd.addr, AC97BusMasterRegs), + VMSTATE_UINT32(bd.ctl_len, AC97BusMasterRegs), + VMSTATE_END_OF_LIST() } }; =20 -static int ac97_post_load (void *opaque, int version_id) +static int ac97_post_load(void *opaque, int version_id) { uint8_t active[LAST_INDEX]; AC97LinkState *s =3D opaque; =20 - record_select (s, mixer_load (s, AC97_Record_Select)); - set_volume (s, AC97_Master_Volume_Mute, - mixer_load (s, AC97_Master_Volume_Mute)); - set_volume (s, AC97_PCM_Out_Volume_Mute, - mixer_load (s, AC97_PCM_Out_Volume_Mute)); - set_volume (s, AC97_Record_Gain_Mute, - mixer_load (s, AC97_Record_Gain_Mute)); + record_select(s, mixer_load(s, AC97_Record_Select)); + set_volume(s, AC97_Master_Volume_Mute, + mixer_load(s, AC97_Master_Volume_Mute)); + set_volume(s, AC97_PCM_Out_Volume_Mute, + mixer_load(s, AC97_PCM_Out_Volume_Mute)); + set_volume(s, AC97_Record_Gain_Mute, + mixer_load(s, AC97_Record_Gain_Mute)); =20 active[PI_INDEX] =3D !!(s->bm_regs[PI_INDEX].cr & CR_RPBM); active[PO_INDEX] =3D !!(s->bm_regs[PO_INDEX].cr & CR_RPBM); active[MC_INDEX] =3D !!(s->bm_regs[MC_INDEX].cr & CR_RPBM); - reset_voices (s, active); + reset_voices(s, active); =20 s->bup_flag =3D 0; s->last_samp =3D 0; return 0; } =20 -static bool is_version_2 (void *opaque, int version_id) +static bool is_version_2(void *opaque, int version_id) { return version_id =3D=3D 2; } @@ -1216,15 +1203,15 @@ static const VMStateDescription vmstate_ac97 =3D { .minimum_version_id =3D 2, .post_load =3D ac97_post_load, .fields =3D (VMStateField[]) { - VMSTATE_PCI_DEVICE (dev, AC97LinkState), - VMSTATE_UINT32 (glob_cnt, AC97LinkState), - VMSTATE_UINT32 (glob_sta, AC97LinkState), - VMSTATE_UINT32 (cas, AC97LinkState), - VMSTATE_STRUCT_ARRAY (bm_regs, AC97LinkState, 3, 1, - vmstate_ac97_bm_regs, AC97BusMasterRegs), - VMSTATE_BUFFER (mixer_data, AC97LinkState), - VMSTATE_UNUSED_TEST (is_version_2, 3), - VMSTATE_END_OF_LIST () + VMSTATE_PCI_DEVICE(dev, AC97LinkState), + VMSTATE_UINT32(glob_cnt, AC97LinkState), + VMSTATE_UINT32(glob_sta, AC97LinkState), + VMSTATE_UINT32(cas, AC97LinkState), + VMSTATE_STRUCT_ARRAY(bm_regs, AC97LinkState, 3, 1, + vmstate_ac97_bm_regs, AC97BusMasterRegs), + VMSTATE_BUFFER(mixer_data, AC97LinkState), + VMSTATE_UNUSED_TEST(is_version_2, 3), + VMSTATE_END_OF_LIST() } }; =20 @@ -1295,7 +1282,7 @@ static uint64_t nabm_read(void *opaque, hwaddr addr, = unsigned size) } =20 static void nabm_write(void *opaque, hwaddr addr, uint64_t val, - unsigned size) + unsigned size) { if ((addr / size) > 64) { return; @@ -1325,20 +1312,20 @@ static const MemoryRegionOps ac97_io_nabm_ops =3D { .endianness =3D DEVICE_LITTLE_ENDIAN, }; =20 -static void ac97_on_reset (DeviceState *dev) +static void ac97_on_reset(DeviceState *dev) { AC97LinkState *s =3D container_of(dev, AC97LinkState, dev.qdev); =20 - reset_bm_regs (s, &s->bm_regs[0]); - reset_bm_regs (s, &s->bm_regs[1]); - reset_bm_regs (s, &s->bm_regs[2]); + reset_bm_regs(s, &s->bm_regs[0]); + reset_bm_regs(s, &s->bm_regs[1]); + reset_bm_regs(s, &s->bm_regs[2]); =20 /* * Reset the mixer too. The Windows XP driver seems to rely on * this. Ats->io_nam, OBJECT(s), &ac97_io_nam_ops, s, - "ac97-nam", 1024); - memory_region_init_io (&s->io_nabm, OBJECT(s), &ac97_io_nabm_ops, s, - "ac97-nabm", 256); - pci_register_bar (&s->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io_nam); - pci_register_bar (&s->dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &s->io_nabm); - AUD_register_card ("ac97", &s->card); + memory_region_init_io(&s->io_nam, OBJECT(s), &ac97_io_nam_ops, s, + "ac97-nam", 1024); + memory_region_init_io(&s->io_nabm, OBJECT(s), &ac97_io_nabm_ops, s, + "ac97-nabm", 256); + pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io_nam); + pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &s->io_nabm); + AUD_register_card("ac97", &s->card); ac97_on_reset(DEVICE(s)); } =20 @@ -1395,13 +1382,13 @@ static void ac97_exit(PCIDevice *dev) =20 static Property ac97_properties[] =3D { DEFINE_AUDIO_PROPERTIES(AC97LinkState, card), - DEFINE_PROP_END_OF_LIST (), + DEFINE_PROP_END_OF_LIST(), }; =20 -static void ac97_class_init (ObjectClass *klass, void *data) +static void ac97_class_init(ObjectClass *klass, void *data) { - DeviceClass *dc =3D DEVICE_CLASS (klass); - PCIDeviceClass *k =3D PCI_DEVICE_CLASS (klass); + DeviceClass *dc =3D DEVICE_CLASS(klass); + PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); =20 k->realize =3D ac97_realize; k->exit =3D ac97_exit; @@ -1419,7 +1406,7 @@ static void ac97_class_init (ObjectClass *klass, void= *data) static const TypeInfo ac97_info =3D { .name =3D TYPE_AC97, .parent =3D TYPE_PCI_DEVICE, - .instance_size =3D sizeof (AC97LinkState), + .instance_size =3D sizeof(AC97LinkState), .class_init =3D ac97_class_init, .interfaces =3D (InterfaceInfo[]) { { INTERFACE_CONVENTIONAL_PCI_DEVICE }, @@ -1427,11 +1414,11 @@ static const TypeInfo ac97_info =3D { }, }; =20 -static void ac97_register_types (void) +static void ac97_register_types(void) { - type_register_static (&ac97_info); + type_register_static(&ac97_info); deprecated_register_soundhw("ac97", "Intel 82801AA AC97 Audio", 0, TYPE_AC97); } =20 -type_init (ac97_register_types) +type_init(ac97_register_types) --=20 2.36.1 From nobody Wed May 15 18:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653507152; cv=none; d=zohomail.com; s=zohoarc; b=nminZ+XxUYU/K/AkcaxjHzUFj+xsLQ1EQvM8wYxVmezGY0APfSS1h0FATfjDt6qETB/hNCEvXU7UMYtEACO3+R36+Ol8Q7LPtB7y50SnLYcLPsk/iMp1SjRo8bCc+CbQfN0hEfPhmdlp8Rq0VdqB/MicT+KFSDgd30gFU6seme0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653507152; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zenkTjX5ljSZMWPTNzlhekDXLg9kHf0n4nzmVZovVqU=; b=XpPyJMhp3vQD1/0L58g0/u+CYiSFPPnbmISXHBFQmxDQ/snyAuMysLK31URmxx9/kYtN9E+Y53A5q5lwy4avJNdEPTjVrtXEofxuJwvGgSRECDEuOlMx0RcurnYzK5txusuSOGxsOpXDdPPC7YaRC0R0rY56PcuIrVn4ghQE4Gs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1653507152544183.7525388912859; Wed, 25 May 2022 12:32:32 -0700 (PDT) Received: from localhost ([::1]:43250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntwkB-00085U-1v for importer@patchew.org; Wed, 25 May 2022 15:32:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwh7-0005Ej-D6 for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:58715) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwh5-0003rG-Q0 for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:21 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-255-WSq7p5SrPLyuaI2IJU-uTw-1; Wed, 25 May 2022 15:29:17 -0400 Received: by mail-ej1-f69.google.com with SMTP id nb10-20020a1709071c8a00b006e8f89863ceso10005207ejc.18 for ; Wed, 25 May 2022 12:29:17 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id ck6-20020a170906c44600b006fecd0501b5sm4062125ejb.98.2022.05.25.12.29.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 12:29:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653506959; 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=zenkTjX5ljSZMWPTNzlhekDXLg9kHf0n4nzmVZovVqU=; b=KkU3eiNUoi9mJ1UR5gx6ZrZcbeZdaVrLrQu0lCDGryePOUplqBG8MH/7UENnL+44WYrB4i T0ssnLQL5QQ8/qHMfRXpeJu8HTTrZI4wX6+kyV40tlmf/NbPzptNjcKAcEWFPDqTYmd0Xp ASwUz5+/CbYAr8UOjoh5wRlw07Zy1ZE= X-MC-Unique: WSq7p5SrPLyuaI2IJU-uTw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zenkTjX5ljSZMWPTNzlhekDXLg9kHf0n4nzmVZovVqU=; b=q3s6IpijeqiinX0lwxCRKmp7Cb4RoE81k16yiGdvDQ2/2g7oGGyMrcHeaAAmCunxi7 9QpFnAQoDFisqVXAkba9ZBWN4hQFSEK9xgJLlQA5as0PJb6Hx07J1i/EMCE7Cvy+k8xW 0XnomjSBa98WYgFlnQTfm4oDpbWO/5UI2TfblGVq/J7WIaEzyl68xisGB+uUfG1yxl/E LrE46rPlhZoZhsBwCp/dhiYp5eVycqOPZQ2arG85mzyP4pmPiomWct/MOPksrdbfA/P3 Ie8hABBaB9/CLBsDmb6FYGUcX/NFQKnEiKKrlU/38O18JvmXdts1VMWFQzwODxivaFL6 s5jg== X-Gm-Message-State: AOAM533YxcVZmfnlsnNvCw4/kSL7yEaAJ/eTLUF72V31Q/QpgI3gwv/M r0yYxmQZiMix/clh3TFth3GAeWTd0ny5AU0KRcD36eckqUjs9tfMUhlZGEqU06GrlFvgEZA1/U8 SQQYGDqzwUL7O7s2lU/OneeNyvsaJ8EbmcAdIeMlJG3g5U6i2yyuxVRcXECC3YEeV0Fw= X-Received: by 2002:a17:906:b7d6:b0:6fe:a34a:a813 with SMTP id fy22-20020a170906b7d600b006fea34aa813mr25402924ejb.551.1653506955932; Wed, 25 May 2022 12:29:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvWK2vIBwMbgNj5gQqZxH8ef+UcpySVmstzRQ4vqz/8ezQE25IVWQniZmwzoDl6n1DB/z2rw== X-Received: by 2002:a17:906:b7d6:b0:6fe:a34a:a813 with SMTP id fy22-20020a170906b7d600b006fea34aa813mr25402906ejb.551.1653506955699; Wed, 25 May 2022 12:29:15 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: BALATON Zoltan , =?UTF-8?q?V=C3=ADctor=20Colombo?= Subject: [PULL 08/17] hw/audio/ac97: Remove unimplemented reset functions Date: Wed, 25 May 2022 21:28:43 +0200 Message-Id: <20220525192852.301633-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525192852.301633-1-pbonzini@redhat.com> References: <20220525192852.301633-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PP_MIME_FAKE_ASCII_TEXT=0.999, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653507154879100001 From: BALATON Zoltan The warm_reset() and cold_reset() functions are not implemented and do nothing so no point in calling them or keep around as dead code. Therefore remove them for now. Signed-off-by: BALATON Zoltan Reviewed-by: V=C3=ADctor Colombo Message-Id: Signed-off-by: Paolo Bonzini --- hw/audio/ac97.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c index 6b1c12bece..6584aa749e 100644 --- a/hw/audio/ac97.c +++ b/hw/audio/ac97.c @@ -222,16 +222,6 @@ static void po_callback(void *opaque, int free); static void pi_callback(void *opaque, int avail); static void mc_callback(void *opaque, int avail); =20 -static void warm_reset(AC97LinkState *s) -{ - (void)s; -} - -static void cold_reset(AC97LinkState *s) -{ - (void)s; -} - static void fetch_bd(AC97LinkState *s, AC97BusMasterRegs *r) { uint8_t b[8]; @@ -921,12 +911,7 @@ static void nabm_writel(void *opaque, uint32_t addr, u= int32_t val) dolog("BDBAR[%d] <- 0x%x (bdbar 0x%x)\n", GET_BM(index), val, r->b= dbar); break; case GLOB_CNT: - if (val & GC_WR) { - warm_reset(s); - } - if (val & GC_CR) { - cold_reset(s); - } + /* TODO: Handle WR or CR being set (warm/cold reset requests) */ if (!(val & (GC_WR | GC_CR))) { s->glob_cnt =3D val & GC_VALID_MASK; } --=20 2.36.1 From nobody Wed May 15 18:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653507628; cv=none; d=zohomail.com; s=zohoarc; b=im6ZRq8PiJyZ7gCl/vyCQoOR2EP6llPJH0ijuYJKSO+QJn50x3Q9BxS42pZw39SxbTUd+S0nBmPw9EcFJi3IPtFUB9N7chftfNIV2Io+rvcLezTZZnZOWuNauFsfzb5jrnY3A/bwInc8ysu8wmX+XApeHjcy6N2mi3LeRpHA/MQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653507628; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=R5G8JJjNfgwnCLIL1ovYhV/3iQZmax8ele6WXpKp+TA=; b=Qzfum1pVLIP09JpJ/Mg15Ibc9fMI9o14R3CG76kfDekXD4prF052nIFwo1CcZfJbRmW9hy9sSFGlpS6oqsibNxuOyLZS6UFwibp4fxNNDKPgqPNK4f3e33qmDOmqk60c14qR4GOCbQ9b7U+AAEGAtKHJDdSxAUGUSBqRc4lQxY8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1653507628509211.0846346891085; Wed, 25 May 2022 12:40:28 -0700 (PDT) Received: from localhost ([::1]:32878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntwrp-0003Rb-HZ for importer@patchew.org; Wed, 25 May 2022 15:40:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhB-0005M8-6G for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:35653) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwh9-0003rV-1g for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:24 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-52-uj_VBgOJOD6QbkqZZYbyCQ-1; Wed, 25 May 2022 15:29:20 -0400 Received: by mail-ed1-f70.google.com with SMTP id r10-20020aa7c14a000000b0042bcc99e4cdso1515405edp.18 for ; Wed, 25 May 2022 12:29:20 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id z8-20020a1709060ac800b006fec5cef701sm4322318ejf.197.2022.05.25.12.29.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 12:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653506962; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R5G8JJjNfgwnCLIL1ovYhV/3iQZmax8ele6WXpKp+TA=; b=cBBvyJxqQP3QU94S1B5CX/qJlXqa8VNtSib/GheHWGCDAtV64j3lCuKvSZ76Sw3T4cesRc ae9XonW7MHBDfz+CuZ7wOEym76O4tMfXBPYv7i2EJ7Mym/NY/WpE1WQQ0XIfWKnmHknALy OS7glx2654/krGzVwDW8/mtsJR1UQi0= X-MC-Unique: uj_VBgOJOD6QbkqZZYbyCQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R5G8JJjNfgwnCLIL1ovYhV/3iQZmax8ele6WXpKp+TA=; b=gtFzHT9ypOliUzZsAeytZQDwTUdYkElSe59wxf/3liujFTeqBR6yF2kTxksWqVmwWL MzdsS8S2qLn6M+e2NHhuy55qLOt7YRSnrTlsCF8xf8hje3SdAsz0jUejtMcyX65HvA7T 4EeqEpnCS9RUb8YQFBY80MlsgkV21vXJFSOrb6za6Th818L8Fa3dj/ydBTqiSAEezkvo jCZtnysmb1ita/VJiNiW+rBvyKi4Cr518DBVNA/lXWhjrMTQJqR6+90FyJOOOXXo/Z2P 4IX4vyhGXG1T8BcQS+FZjaVkPcGOSyowa0nkrmRpUcFF/kBS7RwytECoKzo9uBYByts1 tB+w== X-Gm-Message-State: AOAM531emzZLdEf2vsqFRvgS5P5OFLJvDvgFgoQMie1kEAUzu4EcfFcD TNOhl/7rDyFwf3eyyGbum4acFmuwID54eImXCz5Y5VniPpbhlPCzWUTo12iF3eFcMSsanwjHLTq Y/cU6/0CqxI+VQ4ZsFWi/1hCDMReB4tYUI0pIn667vTGzK1fGXJ2ICh9chSEFI4+1Dik= X-Received: by 2002:a05:6402:1341:b0:42a:f7cb:44dc with SMTP id y1-20020a056402134100b0042af7cb44dcmr35364303edw.165.1653506958339; Wed, 25 May 2022 12:29:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypLbNaXga1g287I1jlxDDifFoX55ZVFSdTuHIMY2jusb/R3LMhk4BDJucNglPWCIZL4sJZng== X-Received: by 2002:a05:6402:1341:b0:42a:f7cb:44dc with SMTP id y1-20020a056402134100b0042af7cb44dcmr35364278edw.165.1653506958029; Wed, 25 May 2022 12:29:18 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Peter Maydell Subject: [PULL 09/17] hw/audio/ac97: Remove unneeded local variables Date: Wed, 25 May 2022 21:28:44 +0200 Message-Id: <20220525192852.301633-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525192852.301633-1-pbonzini@redhat.com> References: <20220525192852.301633-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653507629464100001 Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan Several functions have a local variable that is just a copy of one of the function parameters. This is unneeded complication so just get rid of these. Signed-off-by: BALATON Zoltan Reviewed-by: Peter Maydell Message-Id: Signed-off-by: Paolo Bonzini --- hw/audio/ac97.c | 102 +++++++++++++++++++++++------------------------- 1 file changed, 49 insertions(+), 53 deletions(-) diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c index 6584aa749e..be2dd701a4 100644 --- a/hw/audio/ac97.c +++ b/hw/audio/ac97.c @@ -557,9 +557,8 @@ static uint32_t nam_readb(void *opaque, uint32_t addr) static uint32_t nam_readw(void *opaque, uint32_t addr) { AC97LinkState *s =3D opaque; - uint32_t index =3D addr; s->cas =3D 0; - return mixer_load(s, index); + return mixer_load(s, addr); } =20 static uint32_t nam_readl(void *opaque, uint32_t addr) @@ -584,21 +583,21 @@ static void nam_writeb(void *opaque, uint32_t addr, u= int32_t val) static void nam_writew(void *opaque, uint32_t addr, uint32_t val) { AC97LinkState *s =3D opaque; - uint32_t index =3D addr; + s->cas =3D 0; - switch (index) { + switch (addr) { case AC97_Reset: mixer_reset(s); break; case AC97_Powerdown_Ctrl_Stat: val &=3D ~0x800f; - val |=3D mixer_load(s, index) & 0xf; - mixer_store(s, index, val); + val |=3D mixer_load(s, addr) & 0xf; + mixer_store(s, addr, val); break; case AC97_PCM_Out_Volume_Mute: case AC97_Master_Volume_Mute: case AC97_Record_Gain_Mute: - set_volume(s, index, val); + set_volume(s, addr, val); break; case AC97_Record_Select: record_select(s, val); @@ -626,7 +625,7 @@ static void nam_writew(void *opaque, uint32_t addr, uin= t32_t val) break; case AC97_PCM_Front_DAC_Rate: if (mixer_load(s, AC97_Extended_Audio_Ctrl_Stat) & EACS_VRA) { - mixer_store(s, index, val); + mixer_store(s, addr, val); dolog("Set front DAC rate to %d\n", val); open_voice(s, PO_INDEX, val); } else { @@ -636,7 +635,7 @@ static void nam_writew(void *opaque, uint32_t addr, uin= t32_t val) break; case AC97_MIC_ADC_Rate: if (mixer_load(s, AC97_Extended_Audio_Ctrl_Stat) & EACS_VRM) { - mixer_store(s, index, val); + mixer_store(s, addr, val); dolog("Set MIC ADC rate to %d\n", val); open_voice(s, MC_INDEX, val); } else { @@ -646,7 +645,7 @@ static void nam_writew(void *opaque, uint32_t addr, uin= t32_t val) break; case AC97_PCM_LR_ADC_Rate: if (mixer_load(s, AC97_Extended_Audio_Ctrl_Stat) & EACS_VRA) { - mixer_store(s, index, val); + mixer_store(s, addr, val); dolog("Set front LR ADC rate to %d\n", val); open_voice(s, PI_INDEX, val); } else { @@ -673,7 +672,7 @@ static void nam_writew(void *opaque, uint32_t addr, uin= t32_t val) break; default: dolog("U nam writew 0x%x <- 0x%x\n", addr, val); - mixer_store(s, index, val); + mixer_store(s, addr, val); break; } } @@ -693,10 +692,9 @@ static uint32_t nabm_readb(void *opaque, uint32_t addr) { AC97LinkState *s =3D opaque; AC97BusMasterRegs *r =3D NULL; - uint32_t index =3D addr; uint32_t val =3D ~0U; =20 - switch (index) { + switch (addr) { case CAS: dolog("CAS %d\n", s->cas); val =3D s->cas; @@ -705,37 +703,37 @@ static uint32_t nabm_readb(void *opaque, uint32_t add= r) case PI_CIV: case PO_CIV: case MC_CIV: - r =3D &s->bm_regs[GET_BM(index)]; + r =3D &s->bm_regs[GET_BM(addr)]; val =3D r->civ; - dolog("CIV[%d] -> 0x%x\n", GET_BM(index), val); + dolog("CIV[%d] -> 0x%x\n", GET_BM(addr), val); break; case PI_LVI: case PO_LVI: case MC_LVI: - r =3D &s->bm_regs[GET_BM(index)]; + r =3D &s->bm_regs[GET_BM(addr)]; val =3D r->lvi; - dolog("LVI[%d] -> 0x%x\n", GET_BM(index), val); + dolog("LVI[%d] -> 0x%x\n", GET_BM(addr), val); break; case PI_PIV: case PO_PIV: case MC_PIV: - r =3D &s->bm_regs[GET_BM(index)]; + r =3D &s->bm_regs[GET_BM(addr)]; val =3D r->piv; - dolog("PIV[%d] -> 0x%x\n", GET_BM(index), val); + dolog("PIV[%d] -> 0x%x\n", GET_BM(addr), val); break; case PI_CR: case PO_CR: case MC_CR: - r =3D &s->bm_regs[GET_BM(index)]; + r =3D &s->bm_regs[GET_BM(addr)]; val =3D r->cr; - dolog("CR[%d] -> 0x%x\n", GET_BM(index), val); + dolog("CR[%d] -> 0x%x\n", GET_BM(addr), val); break; case PI_SR: case PO_SR: case MC_SR: - r =3D &s->bm_regs[GET_BM(index)]; + r =3D &s->bm_regs[GET_BM(addr)]; val =3D r->sr & 0xff; - dolog("SRb[%d] -> 0x%x\n", GET_BM(index), val); + dolog("SRb[%d] -> 0x%x\n", GET_BM(addr), val); break; default: dolog("U nabm readb 0x%x -> 0x%x\n", addr, val); @@ -748,23 +746,22 @@ static uint32_t nabm_readw(void *opaque, uint32_t add= r) { AC97LinkState *s =3D opaque; AC97BusMasterRegs *r =3D NULL; - uint32_t index =3D addr; uint32_t val =3D ~0U; =20 - switch (index) { + switch (addr) { case PI_SR: case PO_SR: case MC_SR: - r =3D &s->bm_regs[GET_BM(index)]; + r =3D &s->bm_regs[GET_BM(addr)]; val =3D r->sr; - dolog("SR[%d] -> 0x%x\n", GET_BM(index), val); + dolog("SR[%d] -> 0x%x\n", GET_BM(addr), val); break; case PI_PICB: case PO_PICB: case MC_PICB: - r =3D &s->bm_regs[GET_BM(index)]; + r =3D &s->bm_regs[GET_BM(addr)]; val =3D r->picb; - dolog("PICB[%d] -> 0x%x\n", GET_BM(index), val); + dolog("PICB[%d] -> 0x%x\n", GET_BM(addr), val); break; default: dolog("U nabm readw 0x%x -> 0x%x\n", addr, val); @@ -777,31 +774,30 @@ static uint32_t nabm_readl(void *opaque, uint32_t add= r) { AC97LinkState *s =3D opaque; AC97BusMasterRegs *r =3D NULL; - uint32_t index =3D addr; uint32_t val =3D ~0U; =20 - switch (index) { + switch (addr) { case PI_BDBAR: case PO_BDBAR: case MC_BDBAR: - r =3D &s->bm_regs[GET_BM(index)]; + r =3D &s->bm_regs[GET_BM(addr)]; val =3D r->bdbar; - dolog("BMADDR[%d] -> 0x%x\n", GET_BM(index), val); + dolog("BMADDR[%d] -> 0x%x\n", GET_BM(addr), val); break; case PI_CIV: case PO_CIV: case MC_CIV: - r =3D &s->bm_regs[GET_BM(index)]; + r =3D &s->bm_regs[GET_BM(addr)]; val =3D r->civ | (r->lvi << 8) | (r->sr << 16); - dolog("CIV LVI SR[%d] -> 0x%x, 0x%x, 0x%x\n", GET_BM(index), + dolog("CIV LVI SR[%d] -> 0x%x, 0x%x, 0x%x\n", GET_BM(addr), r->civ, r->lvi, r->sr); break; case PI_PICB: case PO_PICB: case MC_PICB: - r =3D &s->bm_regs[GET_BM(index)]; + r =3D &s->bm_regs[GET_BM(addr)]; val =3D r->picb | (r->piv << 16) | (r->cr << 24); - dolog("PICB PIV CR[%d] -> 0x%x 0x%x 0x%x 0x%x\n", GET_BM(index), + dolog("PICB PIV CR[%d] -> 0x%x 0x%x 0x%x 0x%x\n", GET_BM(addr), val, r->picb, r->piv, r->cr); break; case GLOB_CNT: @@ -827,12 +823,12 @@ static void nabm_writeb(void *opaque, uint32_t addr, = uint32_t val) { AC97LinkState *s =3D opaque; AC97BusMasterRegs *r =3D NULL; - uint32_t index =3D addr; - switch (index) { + + switch (addr) { case PI_LVI: case PO_LVI: case MC_LVI: - r =3D &s->bm_regs[GET_BM(index)]; + r =3D &s->bm_regs[GET_BM(addr)]; if ((r->cr & CR_RPBM) && (r->sr & SR_DCH)) { r->sr &=3D ~(SR_DCH | SR_CELV); r->civ =3D r->piv; @@ -840,12 +836,12 @@ static void nabm_writeb(void *opaque, uint32_t addr, = uint32_t val) fetch_bd(s, r); } r->lvi =3D val % 32; - dolog("LVI[%d] <- 0x%x\n", GET_BM(index), val); + dolog("LVI[%d] <- 0x%x\n", GET_BM(addr), val); break; case PI_CR: case PO_CR: case MC_CR: - r =3D &s->bm_regs[GET_BM(index)]; + r =3D &s->bm_regs[GET_BM(addr)]; if (val & CR_RR) { reset_bm_regs(s, r); } else { @@ -861,15 +857,15 @@ static void nabm_writeb(void *opaque, uint32_t addr, = uint32_t val) voice_set_active(s, r - s->bm_regs, 1); } } - dolog("CR[%d] <- 0x%x (cr 0x%x)\n", GET_BM(index), val, r->cr); + dolog("CR[%d] <- 0x%x (cr 0x%x)\n", GET_BM(addr), val, r->cr); break; case PI_SR: case PO_SR: case MC_SR: - r =3D &s->bm_regs[GET_BM(index)]; + r =3D &s->bm_regs[GET_BM(addr)]; r->sr |=3D val & ~(SR_RO_MASK | SR_WCLEAR_MASK); update_sr(s, r, r->sr & ~(val & SR_WCLEAR_MASK)); - dolog("SR[%d] <- 0x%x (sr 0x%x)\n", GET_BM(index), val, r->sr); + dolog("SR[%d] <- 0x%x (sr 0x%x)\n", GET_BM(addr), val, r->sr); break; default: dolog("U nabm writeb 0x%x <- 0x%x\n", addr, val); @@ -881,15 +877,15 @@ static void nabm_writew(void *opaque, uint32_t addr, = uint32_t val) { AC97LinkState *s =3D opaque; AC97BusMasterRegs *r =3D NULL; - uint32_t index =3D addr; - switch (index) { + + switch (addr) { case PI_SR: case PO_SR: case MC_SR: - r =3D &s->bm_regs[GET_BM(index)]; + r =3D &s->bm_regs[GET_BM(addr)]; r->sr |=3D val & ~(SR_RO_MASK | SR_WCLEAR_MASK); update_sr(s, r, r->sr & ~(val & SR_WCLEAR_MASK)); - dolog("SR[%d] <- 0x%x (sr 0x%x)\n", GET_BM(index), val, r->sr); + dolog("SR[%d] <- 0x%x (sr 0x%x)\n", GET_BM(addr), val, r->sr); break; default: dolog("U nabm writew 0x%x <- 0x%x\n", addr, val); @@ -901,14 +897,14 @@ static void nabm_writel(void *opaque, uint32_t addr, = uint32_t val) { AC97LinkState *s =3D opaque; AC97BusMasterRegs *r =3D NULL; - uint32_t index =3D addr; - switch (index) { + + switch (addr) { case PI_BDBAR: case PO_BDBAR: case MC_BDBAR: - r =3D &s->bm_regs[GET_BM(index)]; + r =3D &s->bm_regs[GET_BM(addr)]; r->bdbar =3D val & ~3; - dolog("BDBAR[%d] <- 0x%x (bdbar 0x%x)\n", GET_BM(index), val, r->b= dbar); + dolog("BDBAR[%d] <- 0x%x (bdbar 0x%x)\n", GET_BM(addr), val, r->bd= bar); break; case GLOB_CNT: /* TODO: Handle WR or CR being set (warm/cold reset requests) */ --=20 2.36.1 From nobody Wed May 15 18:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653507857; cv=none; d=zohomail.com; s=zohoarc; b=dK9xkF5/Eq1mO1h3hAkVnDVGXoRI5c2B3HZR4OHMnOzfGg/4BdJmw/nukhFjxb3D6Y1/xW7TU8gRnXY6vsHsDMCPcaepXUCK6x0jqOv8D5RBuxZBH64MyHAPU2kMooX3dOK77Cu+3D3sDiROccOR3Jvxcg24BrR4fhYzLl4CjOc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653507857; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zji5N8tvYfzPULF1gqHXy1PKmhSyaeVYQ1Ev1V1EIkU=; b=bPvQEBQIJF05wg5U+o8DGTb5tTf2I074EWjD2I4kdkG8/bpxFhOD2KWwpI+8WU8vcw4LmWUDtWE7qY4+iwKq/dt95U4uyzR4pBF6NuEj6cjRYqxGS460nPF3AWG7y8Us1+MDiZe8IZ9EfQpu+/7Jpp+hQaYMlRbA7jbCN0VqLP0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1653507857775389.87221104830815; Wed, 25 May 2022 12:44:17 -0700 (PDT) Received: from localhost ([::1]:39930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntwvY-0008Gq-H7 for importer@patchew.org; Wed, 25 May 2022 15:44:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhC-0005QQ-Rf for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31285) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhB-0003rf-6J for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:26 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-608-XJoSVuHfM-OzSy_UiSCOaw-1; Wed, 25 May 2022 15:29:22 -0400 Received: by mail-ej1-f71.google.com with SMTP id k7-20020a1709062a4700b006fe92440164so9212675eje.23 for ; Wed, 25 May 2022 12:29:22 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id 15-20020a170906004f00b006f3ef214dd9sm8039809ejg.63.2022.05.25.12.29.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 12:29:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653506964; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zji5N8tvYfzPULF1gqHXy1PKmhSyaeVYQ1Ev1V1EIkU=; b=XUVfpgPnXsA2bWi6hMHzQz6lRHwzVnxCuJvSsWm4xFIY2QbCc3ZMyJlu79/E02m2cODX3r lgl8jsrLSgezRXHedACLWTl1v24LpKRptpirt4WoQh7MBhgS4iRqdfnTj2QGiW9q9KULLE xaPooIuhxHstU6ApB4emqogGNJpDDAY= X-MC-Unique: XJoSVuHfM-OzSy_UiSCOaw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zji5N8tvYfzPULF1gqHXy1PKmhSyaeVYQ1Ev1V1EIkU=; b=0jpzvi4Q8puKqehx5NEE3jQt2dpnfvm7jSw2bNGeXm/rkNJ+aUA+ZjcDWue2Z50Y3B XvG9AY/Ic2FHIu7/Xog+ckXwVchqNtRfdB7WH0PfAQT1TArAQGMoOa4kzlrum9URx4Px SARp+/PE6VMk/65sYrG1Mj723+MOU5x8zITCo9jULg6dMI2f/e8QZTAcGFbmmzUItvtD 3euA4nFU6nG8sLNPlvZMTN9gPB0577EozW4r4g0nqM8npzEau39kWBOrk66sQJrWcCol qXPTFu/bQZTfmdUJlK8XsmTalPxRu1V0qkcf0fbKX9w+U0FCfz9+qw5dfR5rKWVDiAuc Sh8Q== X-Gm-Message-State: AOAM5303JvffG+1YTWiP9FZ8pqmhJSCHg2WMFcPzw5PvQbxi+UIZGEcB fSqI1ngauzpf2O0ho1lfn5IrUFYmb/74zLWkuohnVzG6gQobTMHpB5BDQquhfJU3HXgfWvxgI1e TwRwa59PSttmim7sWmamQ1A2fIjeIL+o1EJVFtE1QAHZV/NCiarpUps7yQKMON5rWPP0= X-Received: by 2002:aa7:d2d0:0:b0:42b:c56b:c619 with SMTP id k16-20020aa7d2d0000000b0042bc56bc619mr6163455edr.157.1653506960783; Wed, 25 May 2022 12:29:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOMHsOMcX2q9aKbqrTinJYnr8OhUX0FLAWVKVKHTEwstH4u9N+johCnlg+BQJYlIk14Bfctg== X-Received: by 2002:aa7:d2d0:0:b0:42b:c56b:c619 with SMTP id k16-20020aa7d2d0000000b0042bc56bc619mr6163436edr.157.1653506960441; Wed, 25 May 2022 12:29:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: "Maciej S. Szmigiero" , qemu-stable@nongnu.org Subject: [PULL 10/17] target/i386/kvm: Fix disabling MPX on "-cpu host" with MPX-capable host Date: Wed, 25 May 2022 21:28:45 +0200 Message-Id: <20220525192852.301633-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525192852.301633-1-pbonzini@redhat.com> References: <20220525192852.301633-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653507858884100001 Content-Type: text/plain; charset="utf-8" From: "Maciej S. Szmigiero" Since KVM commit 5f76f6f5ff96 ("KVM: nVMX: Do not expose MPX VMX controls w= hen guest MPX disabled") it is not possible to disable MPX on a "-cpu host" just by adding "-mpx" there if the host CPU does indeed support MPX. QEMU will fail to set MSR_IA32_VMX_TRUE_{EXIT,ENTRY}_CTLS MSRs in this case and so trigger an assertion failure. Instead, besides "-mpx" one has to explicitly add also "-vmx-exit-clear-bndcfgs" and "-vmx-entry-load-bndcfgs" to QEMU command line to make it work, which is a bit convoluted. Make the MPX-related bits in FEAT_VMX_{EXIT,ENTRY}_CTLS dependent on MPX being actually enabled so such workarounds are no longer necessary. Signed-off-by: Maciej S. Szmigiero Message-Id: <51aa2125c76363204cc23c27165e778097c33f0b.1653323077.git.maciej= .szmigiero@oracle.com> Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 35c3475e6c..385691458f 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1355,6 +1355,14 @@ static FeatureDep feature_dependencies[] =3D { .from =3D { FEAT_7_0_EBX, CPUID_7_0_EBX_INVPCID }, .to =3D { FEAT_VMX_SECONDARY_CTLS, VMX_SECONDARY_EXEC_ENABLE_IN= VPCID }, }, + { + .from =3D { FEAT_7_0_EBX, CPUID_7_0_EBX_MPX }, + .to =3D { FEAT_VMX_EXIT_CTLS, VMX_VM_EXIT_CLEAR_BNDCFGS }, + }, + { + .from =3D { FEAT_7_0_EBX, CPUID_7_0_EBX_MPX }, + .to =3D { FEAT_VMX_ENTRY_CTLS, VMX_VM_ENTRY_LOAD_BNDCFGS }, + }, { .from =3D { FEAT_7_0_EBX, CPUID_7_0_EBX_RDSEED }, .to =3D { FEAT_VMX_SECONDARY_CTLS, VMX_SECONDARY_EXEC_RDSEED_EX= ITING }, --=20 2.36.1 From nobody Wed May 15 18:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653508063; cv=none; d=zohomail.com; s=zohoarc; b=n5KtGWL+px4wy64OxzjGg5gD+B0mnOsNLzDNDDb9xQHchnE2rpBM/ITqQCS33QGIucBuIl/9M2sjRpR00vzpsuaRRZ7bIdq4DMo1E62us8vftTyEwyK/iqHyE1o8QR0BqNB1OwMUPzvL2wlz+Jwfc9Nd59cRpnJkvTruSFuZh6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653508063; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EwHG27W5JtNl87FocLffTvijVYGVARLLmOjbH0L9euw=; b=GlKhyxMweLTwLeMTF38jcsRTZQrvgcE/3rYE4x7K3Vzgnprf10bm7m8qap3e45TG/vkO9fhW5cYtL+NctM8audJqVTLAxKpgHSWm5a4rzAukbB/L1aGKTqTrev/R+UhCQ+zRMCeJz3MxnouMnsGLMwyhcO6bET6mLpBspNR+nrM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1653508063417108.49915414020063; Wed, 25 May 2022 12:47:43 -0700 (PDT) Received: from localhost ([::1]:46220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntwys-0004Fs-Ey for importer@patchew.org; Wed, 25 May 2022 15:47:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhF-0005VL-Aw for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47119) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhC-0003rs-Lp for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:29 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-668-JuFEIZp4NYebkML8oA7PUg-1; Wed, 25 May 2022 15:29:25 -0400 Received: by mail-ej1-f70.google.com with SMTP id k7-20020a1709062a4700b006fe92440164so9212716eje.23 for ; Wed, 25 May 2022 12:29:24 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id m25-20020a1709066d1900b006fec6e1d856sm4221665ejr.82.2022.05.25.12.29.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 12:29:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653506966; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EwHG27W5JtNl87FocLffTvijVYGVARLLmOjbH0L9euw=; b=inKt9Mynp9/RWIsfJL6FESHbWDKoeenyoAOsgdCKCFMrTePfwcnRrYn0qTfqQnz6sA6Jpi dj9KK3lsauiPr6TyPohThXM5RTtNlZ5IkjJ6WSyQkKJ2L3G3c9AdzPING1EiL52//ceiUJ 9isBT3SSvAycZPLz3Gjw3IZBZzhGR28= X-MC-Unique: JuFEIZp4NYebkML8oA7PUg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EwHG27W5JtNl87FocLffTvijVYGVARLLmOjbH0L9euw=; b=DlbRz3iUwiF/iQ5dBttZuvoTN76hfa7bV5vrfbxywDO+VP6Rd+xza2DeXCPCCQsLyt ncF7EW06BhWcPFbPjb0l3aNAY2uwR+zSfItTLe0l0lWRxLBRcmCWyXB9P8VubC9hOeSh 6AxqMeNsSCfrfPEgCF9vALCuW2GfN/EylQ57yeWO3tDq//cDQkMXynMwdCffZoCVn0HU EBkTNMnrKm/Nfhkwg5vhlIRxYzgF2zAHDYJGW0/H04R+Zkrnl4+wVaGCU/EF7DhmOlP0 DZa6WUzHPfIhaqFf2mCOt6gRX+b1kyvKrhQYEeQS0A2zhSvPznN8H4kOR+lIJijZhFEl Nddw== X-Gm-Message-State: AOAM530ah1D7QaV7XTmv73ZiUG7mqfTIdSvt98zGcN9fa7eCjdGDOhcR SB+edUfvdrYRVoMh2LDISBA8MWACM/05u4bAbUBzBxH3w+JBR3P1zUIIV4PIVwv7QxVS8i/vM4y qn5yr05Av1ef6sChzceaZVgxoaj+G01GF/aRq+htchCTCkhYKzywHtG7pMW306Lz3OBI= X-Received: by 2002:aa7:ce81:0:b0:42a:ee56:c948 with SMTP id y1-20020aa7ce81000000b0042aee56c948mr36042406edv.388.1653506962999; Wed, 25 May 2022 12:29:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGAP06Ksg3JAO5gUgAlF+nYGwUVUeE0CeY8+9SQscdMfgn2fSoCIwIEM8ByBMkvwstlIfKOw== X-Received: by 2002:aa7:ce81:0:b0:42a:ee56:c948 with SMTP id y1-20020aa7ce81000000b0042aee56c948mr36042384edv.388.1653506962668; Wed, 25 May 2022 12:29:22 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Lev Kujawski Subject: [PULL 11/17] ide_ioport_read: Return lower octet of data register instead of 0xFF Date: Wed, 25 May 2022 21:28:46 +0200 Message-Id: <20220525192852.301633-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525192852.301633-1-pbonzini@redhat.com> References: <20220525192852.301633-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653508064145100001 Content-Type: text/plain; charset="utf-8" From: Lev Kujawski Prior to this patch, the pre-GRUB Solaris x86 bootloader would fail to load on QEMU with the following screen output: SunOS Secondary Boot version 3.00 prom_panic: Could not mount filesystem. Entering boot debugger: [136419]: _ This occurs because the bootloader issues an ATA IDENTIFY DEVICE command, and then reads the resulting 256 words of parameter information using inb rather than the correct inw. As the previous behavior of QEMU was to return 0xFF and not advance the drive's sector buffer, DRQ would never be cleared and the bootloader would be blocked from selecting a secondary ATA device, such as an optical drive. Resolves: * [Bug 1639394] Unable to boot Solaris 8/9 x86 under Fedora 24 Signed-off-by: Lev Kujawski Message-Id: <20220520235200.1138450-1-lkujaw@member.fsf.org> Signed-off-by: Paolo Bonzini --- hw/ide/core.c | 6 +++++- hw/ide/macio.c | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 3a5afff5d7..c2caa54285 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2166,7 +2166,11 @@ uint32_t ide_ioport_read(void *opaque, uint32_t addr) hob =3D bus->cmd & (IDE_CTRL_HOB); switch (reg_num) { case ATA_IOPORT_RR_DATA: - ret =3D 0xff; + /* + * The pre-GRUB Solaris x86 bootloader relies upon inb + * consuming a word from the drive's sector buffer. + */ + ret =3D ide_data_readw(bus, addr) & 0xff; break; case ATA_IOPORT_RR_ERROR: if ((!bus->ifs[0].blk && !bus->ifs[1].blk) || diff --git a/hw/ide/macio.c b/hw/ide/macio.c index f08318cf97..1c15c37ec5 100644 --- a/hw/ide/macio.c +++ b/hw/ide/macio.c @@ -267,7 +267,9 @@ static uint64_t pmac_ide_read(void *opaque, hwaddr addr= , unsigned size) =20 switch (reg) { case 0x0: - if (size =3D=3D 2) { + if (size =3D=3D 1) { + retval =3D ide_data_readw(&d->bus, 0) & 0xFF; + } else if (size =3D=3D 2) { retval =3D ide_data_readw(&d->bus, 0); } else if (size =3D=3D 4) { retval =3D ide_data_readl(&d->bus, 0); --=20 2.36.1 From nobody Wed May 15 18:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653508177; cv=none; d=zohomail.com; s=zohoarc; b=aNiWTKmgY1mAJ6J9nOTBVMgacJ5bFdGc3y/OS2NPQ7ASKKjddiC0WAeoXRE+dp32DqsWu1Tvn46JPfEZrGllWNak59XKlOfGOQqPRre8i2m6qZ7yC96islytIQx+8zJSZGQMsiZ+nSP8TzHUhhIeSYCS+Z2uO45uSOQfo1BnmmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653508177; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gG9nneWWyjnupUUg6wVGpKu/gWNRRTAvNAqk45p9EZU=; b=Ea/yZAUloroYgTbFzuypPmhVVvgC29QFqd4qSuGzxCE4l5/1JykurnDEVX0DY4f+Y0OdOL/MdHj0UYot2Ui8jNZtchV2XT3F9eEQDOxELBkQrPL5EpElg/+/yfxxdPDJO0GyhyZ4fUmTDr5RoM216JLCGPMDRouP9j6hAPkTWlQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1653508177236982.539217213692; Wed, 25 May 2022 12:49:37 -0700 (PDT) Received: from localhost ([::1]:50664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntx0h-0007IU-Mc for importer@patchew.org; Wed, 25 May 2022 15:49:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhH-0005YV-1p for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23833) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhF-0003sA-9t for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:30 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-Hqt4PTxbNA69lrG8KqwAmA-1; Wed, 25 May 2022 15:29:27 -0400 Received: by mail-ej1-f72.google.com with SMTP id k7-20020a1709062a4700b006fe92440164so9212772eje.23 for ; Wed, 25 May 2022 12:29:27 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id ej23-20020a056402369700b0042a2d9af0f8sm11268052edb.79.2022.05.25.12.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 12:29:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653506968; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gG9nneWWyjnupUUg6wVGpKu/gWNRRTAvNAqk45p9EZU=; b=datWObJ9ynHuEV7Yg0bi/cpkkPgZvt8rV5Yi1joj3IMzHBsrLVBT6MuWXJvw6TzZI3a+xG e4hIYtJZetcVFfNzjGN2ZQiv4cKXZSO5w0WTFbTv/9lZzWT0j57Ha19JKORTyZqTFDeu8t yxBLxjU1M1839fmMevRkZBJ4f6p8ztg= X-MC-Unique: Hqt4PTxbNA69lrG8KqwAmA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gG9nneWWyjnupUUg6wVGpKu/gWNRRTAvNAqk45p9EZU=; b=WfFvOM7QGIzw7t/TmSM/pEyo/7xk/0d9+5J41YSeGWncAyuomdxautwku7gr0fjJI/ TbmVbKDsGjjCKWblCe8GSH7jUpRib8AvoSrA7ZVH1BbrCDc5wFNXBLFJhsB8z37DmMzN XlHLUKyCMXAlKuBh+mf663wC6PDa6ggAFXrwdAfN3JBhV3sObIaPd5Ccrh8018/KnXEF p1uSxJEq+8ma2HiMNB1g9wTV1zwFqgwViIYhZtlO/L0ZWkFdyw/jV0qp8l9HMUfFJTkm qJnm+QntQvuvV3bQzyTHFwVG6daZok7ImoRdyrCbg7PB2+QHky3R9dqEp8sLCdFgdvqP lyRw== X-Gm-Message-State: AOAM531E3iJzsdbCyDy3UDonCJNJKC05cF4MkktyopjN5NWOQY6SPoOY iBzxKMEdylt1yNtHUbJZYjsX9EMeClkSpB9YRdXJWlrSx0qrskxv6RXbbjUO80ZElVNa2wOMpal TZK3D/ygH7pY2JQxebdjd2btWccLQTuv8ossRgNpL1wr6g/0NLvYv8oypJEoRz9FdX5o= X-Received: by 2002:a17:906:478b:b0:6f8:5850:4da9 with SMTP id cw11-20020a170906478b00b006f858504da9mr30080741ejc.619.1653506965690; Wed, 25 May 2022 12:29:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyhLSCDttMfLvkvrQaYCw6iwBU9fRaZX/Whp06iIRxQhr/KBB/qWOTt6MT+29oqDec8sgGOg== X-Received: by 2002:a17:906:478b:b0:6f8:5850:4da9 with SMTP id cw11-20020a170906478b00b006f858504da9mr30080714ejc.619.1653506965345; Wed, 25 May 2022 12:29:25 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Vitaly Kuznetsov Subject: [PULL 12/17] i386: Use hv_build_cpuid_leaf() for HV_CPUID_NESTED_FEATURES Date: Wed, 25 May 2022 21:28:47 +0200 Message-Id: <20220525192852.301633-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525192852.301633-1-pbonzini@redhat.com> References: <20220525192852.301633-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653508178977100001 Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov Previously, HV_CPUID_NESTED_FEATURES.EAX CPUID leaf was handled differently as it was only used to encode the supported eVMCS version range. In fact, there are also feature (e.g. Enlightened MSR-Bitmap) bits there. In preparation to adding these features, move HV_CPUID_NESTED_FEATURES leaf handling to hv_build_cpuid_leaf() and drop now-unneeded 'hyperv_nested'. No functional change intended. Signed-off-by: Vitaly Kuznetsov Message-Id: <20220525115949.1294004-2-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 1 - target/i386/kvm/kvm.c | 25 +++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 0d528ac58f..2e918daf6b 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1804,7 +1804,6 @@ struct ArchCPU { uint32_t hyperv_vendor_id[3]; uint32_t hyperv_interface_id[4]; uint32_t hyperv_limits[3]; - uint32_t hyperv_nested[4]; bool hyperv_enforce_cpuid; uint32_t hyperv_ver_id_build; uint16_t hyperv_ver_id_major; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index e2d675115b..38af0e4f04 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -831,6 +831,8 @@ static bool tsc_is_stable_and_known(CPUX86State *env) || env->user_tsc_khz; } =20 +#define DEFAULT_EVMCS_VERSION ((1 << 8) | 1) + static struct { const char *desc; struct { @@ -1254,6 +1256,13 @@ static uint32_t hv_build_cpuid_leaf(CPUState *cs, ui= nt32_t func, int reg) } } =20 + /* HV_CPUID_NESTED_FEATURES.EAX also encodes the supported eVMCS range= */ + if (func =3D=3D HV_CPUID_NESTED_FEATURES && reg =3D=3D R_EAX) { + if (hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS)) { + r |=3D DEFAULT_EVMCS_VERSION; + } + } + return r; } =20 @@ -1384,11 +1393,11 @@ static int hyperv_fill_cpuids(CPUState *cs, struct kvm_cpuid_entry2 *c; uint32_t signature[3]; uint32_t cpuid_i =3D 0, max_cpuid_leaf =3D 0; + uint32_t nested_eax =3D + hv_build_cpuid_leaf(cs, HV_CPUID_NESTED_FEATURES, R_EAX); =20 - max_cpuid_leaf =3D HV_CPUID_IMPLEMENT_LIMITS; - if (hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS)) { - max_cpuid_leaf =3D MAX(max_cpuid_leaf, HV_CPUID_NESTED_FEATURES); - } + max_cpuid_leaf =3D nested_eax ? HV_CPUID_NESTED_FEATURES : + HV_CPUID_IMPLEMENT_LIMITS; =20 if (hyperv_feat_enabled(cpu, HYPERV_FEAT_SYNDBG)) { max_cpuid_leaf =3D @@ -1461,7 +1470,7 @@ static int hyperv_fill_cpuids(CPUState *cs, c->ecx =3D cpu->hyperv_limits[1]; c->edx =3D cpu->hyperv_limits[2]; =20 - if (hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS)) { + if (nested_eax) { uint32_t function; =20 /* Create zeroed 0x40000006..0x40000009 leaves */ @@ -1473,7 +1482,7 @@ static int hyperv_fill_cpuids(CPUState *cs, =20 c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_NESTED_FEATURES; - c->eax =3D cpu->hyperv_nested[0]; + c->eax =3D nested_eax; } =20 if (hyperv_feat_enabled(cpu, HYPERV_FEAT_SYNDBG)) { @@ -1522,8 +1531,6 @@ static bool evmcs_version_supported(uint16_t evmcs_ve= rsion, (max_version <=3D max_supported_version); } =20 -#define DEFAULT_EVMCS_VERSION ((1 << 8) | 1) - static int hyperv_init_vcpu(X86CPU *cpu) { CPUState *cs =3D CPU(cpu); @@ -1620,8 +1627,6 @@ static int hyperv_init_vcpu(X86CPU *cpu) supported_evmcs_version >> 8); return -ENOTSUP; } - - cpu->hyperv_nested[0] =3D evmcs_version; } =20 if (cpu->hyperv_enforce_cpuid) { --=20 2.36.1 From nobody Wed May 15 18:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653507837; cv=none; d=zohomail.com; s=zohoarc; b=Ontw6elXyIbY1AdkYjlLeM/Rhqo0g9I8yL5TKUq4FL+yg6Bj2TIOVqhYqncAUpSadpC4VhJUXNAW5jzwOFRPgNqBmv+vX3W5JQRFMact85lHn8ppSKWCqh3riRQfKs6L1omXk+w9+47c6dwsH/kynKJ3ysV/kGrgjkC9hkC4v2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653507837; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0DzK00baUHTmbKRJ3TcJG4y3BR529hjHpDHgIcJFN/U=; b=YfPA+srBNnd5dIBEVp5h+6Zo/KRHUUjyPkNOxvCcxBEvryWeRQkRymUPXRsZO2QHrzwy7OcGRSs3L4XKhBuY4ivQ3L5SPpFWEhzQ0fZYYK2tv0cBpt2ZRT4BTgVDFlh1kG4iewpOjiqPWjVWqFlel85B6UA30axvuradCvUhZ34= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1653507837168705.3281900095915; Wed, 25 May 2022 12:43:57 -0700 (PDT) Received: from localhost ([::1]:39584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntwv9-00081i-QB for importer@patchew.org; Wed, 25 May 2022 15:43:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhP-0005yv-9m for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58516) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhN-0003sn-GT for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:38 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-592-tkm98hRzNtSAKuFY1a2d3g-1; Wed, 25 May 2022 15:29:29 -0400 Received: by mail-ed1-f71.google.com with SMTP id l18-20020aa7d952000000b0042ab7be9adaso15477755eds.21 for ; Wed, 25 May 2022 12:29:29 -0700 (PDT) Received: from goa-sendmail ([93.56.169.184]) by smtp.gmail.com with ESMTPSA id ev7-20020a17090729c700b006fe9191f47asm4357463ejc.70.2022.05.25.12.29.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 12:29:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653506976; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0DzK00baUHTmbKRJ3TcJG4y3BR529hjHpDHgIcJFN/U=; b=f3dVsDWuyO31gl/sfrncxrYM2xxs4Aa3UrwYkgiq7vhuqtfvO+392NYUfCXK5sKcANXWVy cJXLMMVWh+6k8/lKihykknWYwznRZZgo/x0LifHZxc4oGxsSwy+WiA0c9XWXHXBwhwyXDf Rt+xyiizWIVf0zyLHzOHQxzsMDNjKPU= X-MC-Unique: tkm98hRzNtSAKuFY1a2d3g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0DzK00baUHTmbKRJ3TcJG4y3BR529hjHpDHgIcJFN/U=; b=2PZZpyDyORmo92m44OpG4aIaOXYRJdktck6xdIlO39ojWZayRgoG3IIM3JrXDxm7V+ ulAKcDYt6M3tuOWai86OwIu9whiSZR+Z9i1Vxi/DeBfxA63nXFB8dYwh2+SCZeTZlWNQ 8kQ/H/mO/z2aT2Zj4HZLNNyneUnY8K4I8d/NeXlZy31GT5B0rns5CTj3C8k4ZcGCcCxu 8lsZ1Lm3udZ7aVVGho273vY0TN4d8fK+6XETdwSzhEtzmXBFC6GMZTbfMjtGHjiqkXRf +FOq4rugl6+vmTKk0Ey2AhPVz4zBEsqmTaR4uZiKuYk2D+2dPRo17IUfu0uBThipM/1N 20LA== X-Gm-Message-State: AOAM532R7VCA+VaV0Wohc8mA5lnf9YiwaBwzTD1todUnCOhrQKH0jjiW Y7Ld+dhqQINhCj+qIRG+BVz9jK5nkElv+CbizSQR4SOSY70fhFb2lN6FtlJMfSiBoxv2cACMPcV IPQ2HMWgBsWPROtrKU7/pl6SJ22NRa9kwPJjzKQW/3PCLLrNWTH25Fme2bJ/GR5+u01w= X-Received: by 2002:a17:906:a0d5:b0:6f4:643f:a46f with SMTP id bh21-20020a170906a0d500b006f4643fa46fmr31271269ejb.62.1653506967489; Wed, 25 May 2022 12:29:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPHXeVkibxMNbjSoSQ4Cexwf77UPcVhT2+V8+CWxIBeFpGf6Q9i1bS9Gnk0DW5xzpkTAt4gg== X-Received: by 2002:a17:906:a0d5:b0:6f4:643f:a46f with SMTP id bh21-20020a170906a0d500b006f4643fa46fmr31271242ejb.62.1653506967185; Wed, 25 May 2022 12:29:27 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Vitaly Kuznetsov Subject: [PULL 13/17] i386: Hyper-V Enlightened MSR bitmap feature Date: Wed, 25 May 2022 21:28:48 +0200 Message-Id: <20220525192852.301633-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525192852.301633-1-pbonzini@redhat.com> References: <20220525192852.301633-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653507838933100001 Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov The newly introduced enlightenment allow L0 (KVM) and L1 (Hyper-V) hypervisors to collaborate to avoid unnecessary updates to L2 MSR-Bitmap upon vmexits. Signed-off-by: Vitaly Kuznetsov Message-Id: <20220525115949.1294004-3-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini --- docs/hyperv.txt | 9 +++++++++ target/i386/cpu.h | 1 + target/i386/kvm/hyperv-proto.h | 5 +++++ target/i386/cpu.c | 2 ++ target/i386/kvm/kvm.c | 7 +++++++ 5 files changed, 24 insertions(+) diff --git a/docs/hyperv.txt b/docs/hyperv.txt index 33588a0396..5d85569b99 100644 --- a/docs/hyperv.txt +++ b/docs/hyperv.txt @@ -239,6 +239,15 @@ This enlightenment requires a VMBus device (-device vm= bus-bridge,irq=3D15) and the follow enlightenments to work: hv-relaxed,hv_time,hv-vapic,hv-vpindex,hv-synic,hv-runtime,hv-stimer =20 +3.22. hv-emsr-bitmap +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +The enlightenment is nested specific, it targets Hyper-V on KVM guests. Wh= en +enabled, it allows L0 (KVM) and L1 (Hyper-V) hypervisors to collaborate to +avoid unnecessary updates to L2 MSR-Bitmap upon vmexits. While the protoco= l is +supported for both VMX (Intel) and SVM (AMD), the VMX implementation requi= res +Enlightened VMCS ('hv-evmcs') feature to also be enabled. + +Recommended: hv-evmcs (Intel) =20 4. Supplementary features =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 2e918daf6b..c788285736 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1106,6 +1106,7 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWo= rd w, #define HYPERV_FEAT_STIMER_DIRECT 14 #define HYPERV_FEAT_AVIC 15 #define HYPERV_FEAT_SYNDBG 16 +#define HYPERV_FEAT_MSR_BITMAP 17 =20 #ifndef HYPERV_SPINLOCK_NEVER_NOTIFY #define HYPERV_SPINLOCK_NEVER_NOTIFY 0xFFFFFFFF diff --git a/target/i386/kvm/hyperv-proto.h b/target/i386/kvm/hyperv-proto.h index e40e59411c..cea18dbc0e 100644 --- a/target/i386/kvm/hyperv-proto.h +++ b/target/i386/kvm/hyperv-proto.h @@ -86,6 +86,11 @@ */ #define HV_SYNDBG_CAP_ALLOW_KERNEL_DEBUGGING (1u << 1) =20 +/* + * HV_CPUID_NESTED_FEATURES.EAX bits + */ +#define HV_NESTED_MSR_BITMAP (1u << 19) + /* * Basic virtualized MSRs */ diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 385691458f..474e9b582e 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6968,6 +6968,8 @@ static Property x86_cpu_properties[] =3D { HYPERV_FEAT_STIMER_DIRECT, 0), DEFINE_PROP_BIT64("hv-avic", X86CPU, hyperv_features, HYPERV_FEAT_AVIC, 0), + DEFINE_PROP_BIT64("hv-emsr-bitmap", X86CPU, hyperv_features, + HYPERV_FEAT_MSR_BITMAP, 0), DEFINE_PROP_ON_OFF_AUTO("hv-no-nonarch-coresharing", X86CPU, hyperv_no_nonarch_cs, ON_OFF_AUTO_OFF), DEFINE_PROP_BIT64("hv-syndbg", X86CPU, hyperv_features, diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 38af0e4f04..f389bbedf2 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -973,6 +973,13 @@ static struct { .dependencies =3D BIT(HYPERV_FEAT_SYNIC) | BIT(HYPERV_FEAT_RELAXED) }, #endif + [HYPERV_FEAT_MSR_BITMAP] =3D { + .desc =3D "enlightened MSR-Bitmap (hv-emsr-bitmap)", + .flags =3D { + {.func =3D HV_CPUID_NESTED_FEATURES, .reg =3D R_EAX, + .bits =3D HV_NESTED_MSR_BITMAP} + } + }, }; =20 static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *cs, int max, --=20 2.36.1 From nobody Wed May 15 18:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653508267; cv=none; d=zohomail.com; s=zohoarc; b=lM/+mIX392qCKc5tydEeaBsURY6rpWnT7xtcF5XE1n6Q1uf92CZ4244Hwzk7xVBtjyDgh75GLwWejYJcOo07QXMLZGzX0rZRWQyt0dhebdwV4W719wtGWOt6HGLUUVwCGA/vkBmet0Pv4Mrh+BkWn20pA3fyu9m2WzyaUxDk6Fw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653508267; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=A4COWhg2GjaPXUplNM84dH23IvoIBZrR6ECSXr0Lue8=; b=KaEDqMlaENcFmQIZU377xlCsDRpYHD+uvSMeGNhXlAQJJmfBIA9MpDj+VPgwx1yNVMZXxtEvK74g1NrWvzA8/LOePL3Ho0ArxxtLod06WMJ/5shdOc1m8g3TluQeTpVhaaqt6oK1Jl6F7J3z3Pfqzwxw409q4zq1pFS3gYbVvLs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1653508267864698.1643904776217; Wed, 25 May 2022 12:51:07 -0700 (PDT) Received: from localhost ([::1]:53060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntx2A-0000dK-Fx for importer@patchew.org; Wed, 25 May 2022 15:51:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhL-0005mt-87 for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41686) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhJ-0003sV-8u for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:34 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-664-dOOY2SjcM_6bRBN-YdM7qQ-1; Wed, 25 May 2022 15:29:31 -0400 Received: by mail-ed1-f69.google.com with SMTP id l18-20020aa7d952000000b0042ab7be9adaso15477803eds.21 for ; Wed, 25 May 2022 12:29:31 -0700 (PDT) Received: from goa-sendmail ([93.56.169.184]) by smtp.gmail.com with ESMTPSA id b60-20020a509f42000000b0042bb1e2e2f7sm1561525edf.8.2022.05.25.12.29.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 12:29:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653506972; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A4COWhg2GjaPXUplNM84dH23IvoIBZrR6ECSXr0Lue8=; b=E9GZec7Bq3JPKkgnpbF+jJ3PDpkmmXZdJ7CQ0LhdzTPQDLRvlclgyDnAhoWBegCPfhftM0 lrakvkPTUOfIRwtWZgbJ+DohjeLcwwSnnwZlrzfk+pwsxtweoBjarSi0w8elMH+/wRin90 ofOaVPQRidG6Lrsyj7LPtLbWQx+yyuc= X-MC-Unique: dOOY2SjcM_6bRBN-YdM7qQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A4COWhg2GjaPXUplNM84dH23IvoIBZrR6ECSXr0Lue8=; b=NA5UQ9EQEPtA2Rt1W/8+DtQXq+Zg6ztT1AxQgeLFfSKJl61w/pfAN9+rqHEOdGl5ma mmvcLToATuje1JxkQwwOWTzxGV1E1LhVUEf1f7e+xWyAzwngliYvX1SC8veHyi9rB7c1 qP0/cLK+upCUg7r/hhe6Oikcgqa9CUylIsu0nugRGyTDKTlyu5x3UGorZVMrueymzVqr gUWG6Lv7OjCuCI025/f4vvZvPwA6dQBFDYiCG8JsYPdyRcDRp9OicipZ0iepXVWcVuWi EhBixL31QUTlC1AFhtwC0ZcOEV5UAaTrhCdvjzhJ638VuGetvgtH4q6OWsfi4HRA5CU4 JfIw== X-Gm-Message-State: AOAM530vPr77YblxqIvoaCYB8rsZ7ZUt2Ao+1F/hgxZKctFxgs/v96QS 2hqgp8jzgYJ/IGpNoJGJpgkfy4OlLOE0e085Ko3iAtcuGB1VH+aDm5rfMh2JiXkvjo0PDeVz6ba APjjfLun9cMj8e0A7Fl0LBNz3hDuts7O3FGzY79CQHoPDhFlR2Tap+7j2pSpu1R05vuA= X-Received: by 2002:a17:907:11ce:b0:6fe:9dcc:b983 with SMTP id va14-20020a17090711ce00b006fe9dccb983mr28433156ejb.290.1653506969351; Wed, 25 May 2022 12:29:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWQpB78tjOOs2KW7WwtzarYCGGkeqZvYODchgw8gbgPjlx82qTL5AnXs/E2ublO0nJoHwAAg== X-Received: by 2002:a17:907:11ce:b0:6fe:9dcc:b983 with SMTP id va14-20020a17090711ce00b006fe9dccb983mr28433123ejb.290.1653506968949; Wed, 25 May 2022 12:29:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Vitaly Kuznetsov Subject: [PULL 14/17] i386: Hyper-V XMM fast hypercall input feature Date: Wed, 25 May 2022 21:28:49 +0200 Message-Id: <20220525192852.301633-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525192852.301633-1-pbonzini@redhat.com> References: <20220525192852.301633-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653508269690100001 Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov Hyper-V specification allows to pass parameters for certain hypercalls using XMM registers ("XMM Fast Hypercall Input"). When the feature is in use, it allows for faster hypercalls processing as KVM can avoid reading guest's memory. KVM supports the feature since v5.14. Rename HV_HYPERCALL_{PARAMS_XMM_AVAILABLE -> XMM_INPUT_AVAILABLE} to comply with KVM. Signed-off-by: Vitaly Kuznetsov Message-Id: <20220525115949.1294004-4-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini --- docs/hyperv.txt | 6 ++++++ target/i386/cpu.h | 1 + target/i386/kvm/hyperv-proto.h | 2 +- target/i386/cpu.c | 2 ++ target/i386/kvm/kvm.c | 7 +++++++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/hyperv.txt b/docs/hyperv.txt index 5d85569b99..af1b10c0b3 100644 --- a/docs/hyperv.txt +++ b/docs/hyperv.txt @@ -249,6 +249,12 @@ Enlightened VMCS ('hv-evmcs') feature to also be enabl= ed. =20 Recommended: hv-evmcs (Intel) =20 +3.23. hv-xmm-input +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Hyper-V specification allows to pass parameters for certain hypercalls usi= ng XMM +registers ("XMM Fast Hypercall Input"). When the feature is in use, it all= ows +for faster hypercalls processing as KVM can avoid reading guest's memory. + 4. Supplementary features =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D =20 diff --git a/target/i386/cpu.h b/target/i386/cpu.h index c788285736..37e9553584 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1107,6 +1107,7 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWo= rd w, #define HYPERV_FEAT_AVIC 15 #define HYPERV_FEAT_SYNDBG 16 #define HYPERV_FEAT_MSR_BITMAP 17 +#define HYPERV_FEAT_XMM_INPUT 18 =20 #ifndef HYPERV_SPINLOCK_NEVER_NOTIFY #define HYPERV_SPINLOCK_NEVER_NOTIFY 0xFFFFFFFF diff --git a/target/i386/kvm/hyperv-proto.h b/target/i386/kvm/hyperv-proto.h index cea18dbc0e..f5f16474fa 100644 --- a/target/i386/kvm/hyperv-proto.h +++ b/target/i386/kvm/hyperv-proto.h @@ -54,7 +54,7 @@ #define HV_GUEST_DEBUGGING_AVAILABLE (1u << 1) #define HV_PERF_MONITOR_AVAILABLE (1u << 2) #define HV_CPU_DYNAMIC_PARTITIONING_AVAILABLE (1u << 3) -#define HV_HYPERCALL_PARAMS_XMM_AVAILABLE (1u << 4) +#define HV_HYPERCALL_XMM_INPUT_AVAILABLE (1u << 4) #define HV_GUEST_IDLE_STATE_AVAILABLE (1u << 5) #define HV_FREQUENCY_MSRS_AVAILABLE (1u << 8) #define HV_GUEST_CRASH_MSR_AVAILABLE (1u << 10) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 474e9b582e..63cec0ea68 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6970,6 +6970,8 @@ static Property x86_cpu_properties[] =3D { HYPERV_FEAT_AVIC, 0), DEFINE_PROP_BIT64("hv-emsr-bitmap", X86CPU, hyperv_features, HYPERV_FEAT_MSR_BITMAP, 0), + DEFINE_PROP_BIT64("hv-xmm-input", X86CPU, hyperv_features, + HYPERV_FEAT_XMM_INPUT, 0), DEFINE_PROP_ON_OFF_AUTO("hv-no-nonarch-coresharing", X86CPU, hyperv_no_nonarch_cs, ON_OFF_AUTO_OFF), DEFINE_PROP_BIT64("hv-syndbg", X86CPU, hyperv_features, diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index f389bbedf2..7e6f934eda 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -980,6 +980,13 @@ static struct { .bits =3D HV_NESTED_MSR_BITMAP} } }, + [HYPERV_FEAT_XMM_INPUT] =3D { + .desc =3D "XMM fast hypercall input (hv-xmm-input)", + .flags =3D { + {.func =3D HV_CPUID_FEATURES, .reg =3D R_EDX, + .bits =3D HV_HYPERCALL_XMM_INPUT_AVAILABLE} + } + }, }; =20 static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *cs, int max, --=20 2.36.1 From nobody Wed May 15 18:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653507468; cv=none; d=zohomail.com; s=zohoarc; b=fTfIf7SJaAMU7E7Wj3+FJX6iuoktEPjHk/d/Qi1izdFhOld1BHAimDCYYMfveZz85aS+ZGksldtlgldJayx92DeCRR3zMwjZoFSCS935Z7ONRQ8mMfs1vc78qHId1sDp9kIwledjXf8TNKO4RuiG+6NmL0+4VE8YtYIXzUyLXmE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653507468; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xyaAVt5qF1/CRxSwd34RasuaWblBBQKY8e8rZNkUw3c=; b=fPxXGjUpcCGxzhwQOLc93EBD3+vuSo7E6BNMqvxRohhYCYuvLAcfSPA/33XjOFJ5BPNMC/xlt3EA+e5DEgceg9NWGaMjOG98Rp75S0d4o7mJrq2hEtOkSqr4bX9dojsk9vT0jVZd6ks3BTAQOdf9k8NQwnX4JroGp2NhE523KAw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1653507468370299.3830424526251; Wed, 25 May 2022 12:37:48 -0700 (PDT) Received: from localhost ([::1]:55184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntwpH-0007jm-8C for importer@patchew.org; Wed, 25 May 2022 15:37:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhQ-00060w-4U for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:25631) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhL-0003sd-57 for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:39 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-197--HVcI9mtN7uqlS_9vHzHlA-1; Wed, 25 May 2022 15:29:32 -0400 Received: by mail-ej1-f72.google.com with SMTP id bt15-20020a170906b14f00b006fe9c3afbc2so8319201ejb.17 for ; Wed, 25 May 2022 12:29:32 -0700 (PDT) Received: from goa-sendmail ([93.56.169.184]) by smtp.gmail.com with ESMTPSA id y20-20020a50eb94000000b0042617ba63c4sm10993201edr.78.2022.05.25.12.29.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 12:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653506974; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xyaAVt5qF1/CRxSwd34RasuaWblBBQKY8e8rZNkUw3c=; b=Z1MtpvREHe4ZPNHGloClv7q7bkzLhNF0GIsReI+u1gvTNlCblx3QvaOMPMoG1qbaQLaifs WUGDjeiFQmMET5JeSwacbjNFc/2F5VIslcZ2xNro8OstvxwoWXLyKrZQC4xxNostz40vyL IrVAN4C9Z3yfAoy3VCCjsEfy1lohC8k= X-MC-Unique: -HVcI9mtN7uqlS_9vHzHlA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xyaAVt5qF1/CRxSwd34RasuaWblBBQKY8e8rZNkUw3c=; b=OI0Opw1lNBcq+XWDDVYOegLz6vSqdOT4uIgSrcTdFZwr1VCuCiHoWwvnq11FEw3gy9 RnARAUw9awQI5zdheVSjxRR9v+80vAPt5GM3rCw+Cb9SsyqAqu7XV8MjclMO8AnaQaRC wkXfjeswQiVhl14JcVhaERdBQtq4UmrGWgt+NXXrOtGJTcRfUuJ05qD7iBxwq+fiuMir qIfoZJ8y58zpc7fVZUyhYq26nuy6n9BXHZY9u/a/VHwiGBAnR/FMbhHSeTg9MdfXwtdN glBl0+2SMroAKb5VpVf0p8cvCowEQfPdZs3gKVXVV2uG6qk7S/TgmOE+tIvS64eeNhof eohw== X-Gm-Message-State: AOAM531wAiaCnJQal16oT3GnbSJnfcUa8In0gwfJxc6GUeCVWm+6u6GI tiGQbIjSCwY5yQ1hkHlOBRwtvThGE9L4tMX8F/ErUUiUG7TYeIC4yURsjvftORzGj8xx3zzTp0C MG74SiZ5Q0+pELVr9krOjObyANjwzy9Wv/HRd8HGiqv4ZqrUUMxYIxtnPrBEPIlETyA4= X-Received: by 2002:a17:906:52c7:b0:6ce:a880:50a3 with SMTP id w7-20020a17090652c700b006cea88050a3mr30022194ejn.437.1653506971102; Wed, 25 May 2022 12:29:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIOPBPnZlUqEYXWPjstgOay212ZAwwHV3CHiYBgzOcApzDGAAiq/8d4tq2xFWXXrHLOgIuWg== X-Received: by 2002:a17:906:52c7:b0:6ce:a880:50a3 with SMTP id w7-20020a17090652c700b006cea88050a3mr30022177ejn.437.1653506970820; Wed, 25 May 2022 12:29:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Vitaly Kuznetsov Subject: [PULL 15/17] i386: Hyper-V Support extended GVA ranges for TLB flush hypercalls Date: Wed, 25 May 2022 21:28:50 +0200 Message-Id: <20220525192852.301633-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525192852.301633-1-pbonzini@redhat.com> References: <20220525192852.301633-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653507470249100001 Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov KVM kind of supported "extended GVA ranges" (up to 4095 additional GFNs per hypercall) since the implementation of Hyper-V PV TLB flush feature (Linux-4.18) as regardless of the request, full TLB flush was always performed. "Extended GVA ranges for TLB flush hypercalls" feature bit wasn't exposed then. Now, as KVM gains support for fine-grained TLB flush handling, exposing this feature starts making sense. Signed-off-by: Vitaly Kuznetsov Message-Id: <20220525115949.1294004-5-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini --- docs/hyperv.txt | 7 +++++++ target/i386/cpu.h | 1 + target/i386/kvm/hyperv-proto.h | 1 + target/i386/cpu.c | 2 ++ target/i386/kvm/kvm.c | 8 ++++++++ 5 files changed, 19 insertions(+) diff --git a/docs/hyperv.txt b/docs/hyperv.txt index af1b10c0b3..4b132b1c94 100644 --- a/docs/hyperv.txt +++ b/docs/hyperv.txt @@ -255,6 +255,13 @@ Hyper-V specification allows to pass parameters for ce= rtain hypercalls using XMM registers ("XMM Fast Hypercall Input"). When the feature is in use, it all= ows for faster hypercalls processing as KVM can avoid reading guest's memory. =20 +3.24. hv-tlbflush-ext +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Allow for extended GVA ranges to be passed to Hyper-V TLB flush hypercalls +(HvFlushVirtualAddressList/HvFlushVirtualAddressListEx). + +Requires: hv-tlbflush + 4. Supplementary features =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D =20 diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 37e9553584..5ff48257e5 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1108,6 +1108,7 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWo= rd w, #define HYPERV_FEAT_SYNDBG 16 #define HYPERV_FEAT_MSR_BITMAP 17 #define HYPERV_FEAT_XMM_INPUT 18 +#define HYPERV_FEAT_TLBFLUSH_EXT 19 =20 #ifndef HYPERV_SPINLOCK_NEVER_NOTIFY #define HYPERV_SPINLOCK_NEVER_NOTIFY 0xFFFFFFFF diff --git a/target/i386/kvm/hyperv-proto.h b/target/i386/kvm/hyperv-proto.h index f5f16474fa..c7854ed6d3 100644 --- a/target/i386/kvm/hyperv-proto.h +++ b/target/i386/kvm/hyperv-proto.h @@ -59,6 +59,7 @@ #define HV_FREQUENCY_MSRS_AVAILABLE (1u << 8) #define HV_GUEST_CRASH_MSR_AVAILABLE (1u << 10) #define HV_FEATURE_DEBUG_MSRS_AVAILABLE (1u << 11) +#define HV_EXT_GVA_RANGES_FLUSH_AVAILABLE (1u << 14) #define HV_STIMER_DIRECT_MODE_AVAILABLE (1u << 19) =20 /* diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 63cec0ea68..3429a4e455 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6972,6 +6972,8 @@ static Property x86_cpu_properties[] =3D { HYPERV_FEAT_MSR_BITMAP, 0), DEFINE_PROP_BIT64("hv-xmm-input", X86CPU, hyperv_features, HYPERV_FEAT_XMM_INPUT, 0), + DEFINE_PROP_BIT64("hv-tlbflush-ext", X86CPU, hyperv_features, + HYPERV_FEAT_TLBFLUSH_EXT, 0), DEFINE_PROP_ON_OFF_AUTO("hv-no-nonarch-coresharing", X86CPU, hyperv_no_nonarch_cs, ON_OFF_AUTO_OFF), DEFINE_PROP_BIT64("hv-syndbg", X86CPU, hyperv_features, diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 7e6f934eda..a11c8e88f6 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -987,6 +987,14 @@ static struct { .bits =3D HV_HYPERCALL_XMM_INPUT_AVAILABLE} } }, + [HYPERV_FEAT_TLBFLUSH_EXT] =3D { + .desc =3D "Extended gva ranges for TLB flush hypercalls (hv-tlbflu= sh-ext)", + .flags =3D { + {.func =3D HV_CPUID_FEATURES, .reg =3D R_EDX, + .bits =3D HV_EXT_GVA_RANGES_FLUSH_AVAILABLE} + }, + .dependencies =3D BIT(HYPERV_FEAT_TLBFLUSH) + }, }; =20 static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *cs, int max, --=20 2.36.1 From nobody Wed May 15 18:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653507703; cv=none; d=zohomail.com; s=zohoarc; b=aEVFsLndco7Sr6Q49ODf8ADcy7XUxMRzjeT02ShasJb9LGYsdNCGfY4eNWWj/V9GEDOfsf/ltd7xXlmnbDyMeN6+C87msBIa36/O6uNnDX8OahNGOqdYo9XFFXCMKIrPT7mhnZgnFKu/Rn66ICB7Fs8gtHVHT9HfWi3A0KUovuk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653507703; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HL2VaOZYrg2xIPskTQpaLR0aHr3OzfHOd1xRp891uVc=; b=O/5nhN64q2ZA5H1tQhtUJreYXxF7Mwh+IthG99rJ7/USacewURbFr5qdtXmu/wVIX2T0vYs7ZPVsMGf3VbKeS181S4RZdiNo1lnc8792cJB64cUKSvtH0Z/TAPFgQxtmW1rMdFJ+tU9XCtSgfLXF/wL8QnysfyEl0Lme4hV34Ig= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1653507703901515.3570678057368; Wed, 25 May 2022 12:41:43 -0700 (PDT) Received: from localhost ([::1]:35442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntwt3-0005Fn-Oj for importer@patchew.org; Wed, 25 May 2022 15:41:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhQ-000634-QH for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhO-0003ss-9J for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:40 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-186-sa68kAzkMrOeuGpCndLEkg-1; Wed, 25 May 2022 15:29:35 -0400 Received: by mail-ed1-f72.google.com with SMTP id u1-20020aa7d981000000b0042acd1f2253so15455627eds.4 for ; Wed, 25 May 2022 12:29:34 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id 15-20020a170906004f00b006f3ef214dd9sm8039944ejg.63.2022.05.25.12.29.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 12:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653506977; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HL2VaOZYrg2xIPskTQpaLR0aHr3OzfHOd1xRp891uVc=; b=MG7ZgVEUVmWZWizl0y4jTKAUCnZgRXX3c2VEvU5Rw7dTf8wjAPmTtYBQ4q236SBcc/vR+F wck6Mb/IfGG6O7JfSMXG+kAbDB/HdCN6uV9IE3gMoBsWh61nOCKl3+2kaBXhPHF+IaSNip bN2ybL4KxpsDcl8YNYD+eU8BgDSX7Qc= X-MC-Unique: sa68kAzkMrOeuGpCndLEkg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HL2VaOZYrg2xIPskTQpaLR0aHr3OzfHOd1xRp891uVc=; b=zZ/lMVxgcx+w0j5h1jjZYanDUc0nj+l7EjPtfZzUN0EoyFMgtdI1K7YP+wt66iVM/h 11g8nORadxN8IqxILzH/7oZv60zgXvFEkrzglMWLjtBGrBGKMDDOzzNfKoAtXUWGU3GT WXy9QmBtu0W/YMYF6kO3VLjuTqok0OO3watV+RQXYmOO5O/cyhDv0H0Va/K7TFsH5KcS pkic8FLfa1UWKMYMnZ2fLuTqDJUdfQ670TqHsYsF/YfXTsTG5PXSCK+A8BgITEBKDqJg hap419wTs0jhU8AEWaGG0zyTXalz8WSZdxbtYFKz9eCqNZ10Dbx4hfD+MLCf9wRahyDa 1pgw== X-Gm-Message-State: AOAM531cHdeKKCyPwC5MZOuA1wJZfhdbsK3NehIIsWmpQXHrAIKdbrjZ EgJLgouymo8oMbKN1FRlZ9WQMCI6u5Q+S/3H70DPtWwWkz/4YLT/tz9I+amV1Not+Nhx86t+xAN H8b0/ANQs4qdniuGxr9CNtMCyB604Z+69ocxtaEoqZ604NiJ8HNvPFsyehLcHaInit6M= X-Received: by 2002:a05:6402:1910:b0:42b:5046:7f88 with SMTP id e16-20020a056402191000b0042b50467f88mr21672911edz.319.1653506973253; Wed, 25 May 2022 12:29:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwREZtYiamBmN5xxxBLU5QCU8azYrY+w04eyAn1uWNw95C5dekB9rv+RwZMsNC4LJpNSfk/pw== X-Received: by 2002:a05:6402:1910:b0:42b:5046:7f88 with SMTP id e16-20020a056402191000b0042b50467f88mr21672889edz.319.1653506972949; Wed, 25 May 2022 12:29:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Vitaly Kuznetsov Subject: [PULL 16/17] i386: Hyper-V Direct TLB flush hypercall Date: Wed, 25 May 2022 21:28:51 +0200 Message-Id: <20220525192852.301633-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525192852.301633-1-pbonzini@redhat.com> References: <20220525192852.301633-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653507704124100001 Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov Hyper-V TLFS allows for L0 and L1 hypervisors to collaborate on L2's TLB flush hypercalls handling. With the correct setup, L2's TLB flush hypercalls can be handled by L0 directly, without the need to exit to L1. Signed-off-by: Vitaly Kuznetsov Message-Id: <20220525115949.1294004-6-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini --- docs/hyperv.txt | 11 +++++++++++ target/i386/cpu.h | 1 + target/i386/kvm/hyperv-proto.h | 1 + target/i386/cpu.c | 2 ++ target/i386/kvm/kvm.c | 8 ++++++++ 5 files changed, 23 insertions(+) diff --git a/docs/hyperv.txt b/docs/hyperv.txt index 4b132b1c94..14a7f449ea 100644 --- a/docs/hyperv.txt +++ b/docs/hyperv.txt @@ -262,6 +262,17 @@ Allow for extended GVA ranges to be passed to Hyper-V = TLB flush hypercalls =20 Requires: hv-tlbflush =20 +3.25. hv-tlbflush-direct +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D +The enlightenment is nested specific, it targets Hyper-V on KVM guests. Wh= en +enabled, it allows L0 (KVM) to directly handle TLB flush hypercalls from L2 +guest without the need to exit to L1 (Hyper-V) hypervisor. While the featu= re is +supported for both VMX (Intel) and SVM (AMD), the VMX implementation requi= res +Enlightened VMCS ('hv-evmcs') feature to also be enabled. + +Requires: hv-vapic +Recommended: hv-evmcs (Intel) + 4. Supplementary features =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D =20 diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 5ff48257e5..82004b65b9 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1109,6 +1109,7 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWo= rd w, #define HYPERV_FEAT_MSR_BITMAP 17 #define HYPERV_FEAT_XMM_INPUT 18 #define HYPERV_FEAT_TLBFLUSH_EXT 19 +#define HYPERV_FEAT_TLBFLUSH_DIRECT 20 =20 #ifndef HYPERV_SPINLOCK_NEVER_NOTIFY #define HYPERV_SPINLOCK_NEVER_NOTIFY 0xFFFFFFFF diff --git a/target/i386/kvm/hyperv-proto.h b/target/i386/kvm/hyperv-proto.h index c7854ed6d3..464fbf09e3 100644 --- a/target/i386/kvm/hyperv-proto.h +++ b/target/i386/kvm/hyperv-proto.h @@ -90,6 +90,7 @@ /* * HV_CPUID_NESTED_FEATURES.EAX bits */ +#define HV_NESTED_DIRECT_FLUSH (1u << 17) #define HV_NESTED_MSR_BITMAP (1u << 19) =20 /* diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 3429a4e455..bb6a5dd498 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6974,6 +6974,8 @@ static Property x86_cpu_properties[] =3D { HYPERV_FEAT_XMM_INPUT, 0), DEFINE_PROP_BIT64("hv-tlbflush-ext", X86CPU, hyperv_features, HYPERV_FEAT_TLBFLUSH_EXT, 0), + DEFINE_PROP_BIT64("hv-tlbflush-direct", X86CPU, hyperv_features, + HYPERV_FEAT_TLBFLUSH_DIRECT, 0), DEFINE_PROP_ON_OFF_AUTO("hv-no-nonarch-coresharing", X86CPU, hyperv_no_nonarch_cs, ON_OFF_AUTO_OFF), DEFINE_PROP_BIT64("hv-syndbg", X86CPU, hyperv_features, diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index a11c8e88f6..f148a6d52f 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -995,6 +995,14 @@ static struct { }, .dependencies =3D BIT(HYPERV_FEAT_TLBFLUSH) }, + [HYPERV_FEAT_TLBFLUSH_DIRECT] =3D { + .desc =3D "direct TLB flush (hv-tlbflush-direct)", + .flags =3D { + {.func =3D HV_CPUID_NESTED_FEATURES, .reg =3D R_EAX, + .bits =3D HV_NESTED_DIRECT_FLUSH} + }, + .dependencies =3D BIT(HYPERV_FEAT_VAPIC) + }, }; =20 static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *cs, int max, --=20 2.36.1 From nobody Wed May 15 18:41:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653508363; cv=none; d=zohomail.com; s=zohoarc; b=YM1gU5N7WcBYugr9HvjnUch97QmBLz/N6EP3yBU9GkmdVPyZ4tTaSE7P3dEIf+OPGplOEQAGjm4oRkcMrK2ze9qkwCLkg8IoniAtZqHMSAg6wQ44r5oTBsko+42KCokL/LaMkDFHJyd5uds/Vk7n/ufLYCVt5FbiovIxHGtrIcc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653508363; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2ckAbV5ApLY4wP2czWLCEqvjx2t0XKakAecR9S/oPrY=; b=J6m1tIe54LgKr6zCMpaLIe0Ic/ZbK0nb2F0JeyqO0nAcXOxOTEv1wiJDtXVTuD6Jq1ev1DyJL+mqZhi6j2Sw0on0mT31BmClvcmGG9PVE7zwk6oJf+aPy4fgcsxQFzKIjl9R4xr2mO6tpLnZKdIh9TEj2s7uxibJ5rRsSQrDfsU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1653508363941917.248740561248; Wed, 25 May 2022 12:52:43 -0700 (PDT) Received: from localhost ([::1]:55188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntx3i-0002CC-Qt for importer@patchew.org; Wed, 25 May 2022 15:52:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhi-0006RJ-1i for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44113) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntwhS-0003uV-FV for qemu-devel@nongnu.org; Wed, 25 May 2022 15:29:57 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-102-ZaV6AHeCNC-VsvmuOzLBQg-1; Wed, 25 May 2022 15:29:38 -0400 Received: by mail-ej1-f69.google.com with SMTP id gf24-20020a170906e21800b006fe8e7f8783so9598567ejb.2 for ; Wed, 25 May 2022 12:29:37 -0700 (PDT) Received: from goa-sendmail ([93.56.169.184]) by smtp.gmail.com with ESMTPSA id u4-20020a17090617c400b006f3ef214e77sm4032618eje.221.2022.05.25.12.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 12:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653506980; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2ckAbV5ApLY4wP2czWLCEqvjx2t0XKakAecR9S/oPrY=; b=Nq1IKsXshUONwtO+XfjHPFd5hbs4KS/tV4SuBnn4X/Osh3W4Rv3rQC4CCgIDqN1jE9SEjG Xmf19kQocixYlm3eb/oNi64+wZjjoP2U2IYtT/pOZIUcQjC3T5L9hR32jp9QacyO2bAw5h DOo+cyZV2RtGsjC8iRI0QML8tTKT1dA= X-MC-Unique: ZaV6AHeCNC-VsvmuOzLBQg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2ckAbV5ApLY4wP2czWLCEqvjx2t0XKakAecR9S/oPrY=; b=BjeCUh8H3gLzlgabKAZ65nFjPbrDqnQCW7/C6+om35b7Ek4glkuhGpIzp6dX1iMTOY Nzd2M+xwTSU4Gq7TbEJGdRjf/+k/mvFHmVUb3A05e5yL0UV+ZHZw9R3BYhtyZfAFRWVT rbIEsMC4PGLPwp2x1Fe+3/+uXqwB2xITvgt4D6r2EL+iXhyukwmGrgKsZXVYH21a5c1S t7QvRChTmwOZ5qS2PVMtXIu2jR0vNlhD8phhIhTbptWlV/fjBZ/kCJOnHV/lxxoHCdpD 80Br/ssw9bCAYv8kMMqaCA8lp1PfrzoXmDKg7+qeDqDeS4owYhAEu12J/oVHZBCD0oYd wSWQ== X-Gm-Message-State: AOAM532Fb7rKDmdotJo5kIn5XgEcM8ok9aOpMdR8W5GYDazlH2vVyRAN 7TBwre4MFQ+hmJATfT4kM39dJEpru+UMeo53szpx4C8LNX3pj/f4SAffn+k3gx3lJOLB+nfsRky HRQaICay2VpTQWdZYQtGgleWhXnkAXxxMZIvLX1v0oU8VcyHFiHg83E5qp0cPHAGjPAM= X-Received: by 2002:a17:906:751:b0:6fe:a036:b357 with SMTP id z17-20020a170906075100b006fea036b357mr27104690ejb.185.1653506975697; Wed, 25 May 2022 12:29:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLBDx0rzzRphonZFMX1OZIW2BjJpnTZfaCSuyQbsoM2muT3hTAZoyJkje9pzjEKw7tGIoHkw== X-Received: by 2002:a17:906:751:b0:6fe:a036:b357 with SMTP id z17-20020a170906075100b006fea036b357mr27104641ejb.185.1653506974740; Wed, 25 May 2022 12:29:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Vitaly Kuznetsov Subject: [PULL 17/17] i386: docs: Convert hyperv.txt to rST Date: Wed, 25 May 2022 21:28:52 +0200 Message-Id: <20220525192852.301633-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525192852.301633-1-pbonzini@redhat.com> References: <20220525192852.301633-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653508364219100001 Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov rSTify docs/hyperv.txt and link it from docs/system/target-i386.rst. Signed-off-by: Vitaly Kuznetsov Message-Id: <20220525115949.1294004-7-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini --- docs/hyperv.txt | 303 ------------------------------------ docs/system/i386/hyperv.rst | 288 ++++++++++++++++++++++++++++++++++ docs/system/target-i386.rst | 1 + 3 files changed, 289 insertions(+), 303 deletions(-) delete mode 100644 docs/hyperv.txt create mode 100644 docs/system/i386/hyperv.rst diff --git a/docs/hyperv.txt b/docs/hyperv.txt deleted file mode 100644 index 14a7f449ea..0000000000 --- a/docs/hyperv.txt +++ /dev/null @@ -1,303 +0,0 @@ -Hyper-V Enlightenments -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - - -1. Description -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -In some cases when implementing a hardware interface in software is slow, = KVM -implements its own paravirtualized interfaces. This works well for Linux as -guest support for such features is added simultaneously with the feature i= tself. -It may, however, be hard-to-impossible to add support for these interfaces= to -proprietary OSes, namely, Microsoft Windows. - -KVM on x86 implements Hyper-V Enlightenments for Windows guests. These fea= tures -make Windows and Hyper-V guests think they're running on top of a Hyper-V -compatible hypervisor and use Hyper-V specific features. - - -2. Setup -=3D=3D=3D=3D=3D=3D=3D=3D=3D -No Hyper-V enlightenments are enabled by default by either KVM or QEMU. In -QEMU, individual enlightenments can be enabled through CPU flags, e.g: - - qemu-system-x86_64 --enable-kvm --cpu host,hv_relaxed,hv_vpindex,hv_time= , ... - -Sometimes there are dependencies between enlightenments, QEMU is supposed = to -check that the supplied configuration is sane. - -When any set of the Hyper-V enlightenments is enabled, QEMU changes hyperv= isor -identification (CPUID 0x40000000..0x4000000A) to Hyper-V. KVM identificati= on -and features are kept in leaves 0x40000100..0x40000101. - - -3. Existing enlightenments -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D - -3.1. hv-relaxed -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -This feature tells guest OS to disable watchdog timeouts as it is running = on a -hypervisor. It is known that some Windows versions will do this even when = they -see 'hypervisor' CPU flag. - -3.2. hv-vapic -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Provides so-called VP Assist page MSR to guest allowing it to work with AP= IC -more efficiently. In particular, this enlightenment allows paravirtualized -(exit-less) EOI processing. - -3.3. hv-spinlocks=3Dxxx -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Enables paravirtualized spinlocks. The parameter indicates how many times -spinlock acquisition should be attempted before indicating the situation t= o the -hypervisor. A special value 0xffffffff indicates "never notify". - -3.4. hv-vpindex -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Provides HV_X64_MSR_VP_INDEX (0x40000002) MSR to the guest which has Virtu= al -processor index information. This enlightenment makes sense in conjunction= with -hv-synic, hv-stimer and other enlightenments which require the guest to kn= ow its -Virtual Processor indices (e.g. when VP index needs to be passed in a -hypercall). - -3.5. hv-runtime -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Provides HV_X64_MSR_VP_RUNTIME (0x40000010) MSR to the guest. The MSR keep= s the -virtual processor run time in 100ns units. This gives guest operating syst= em an -idea of how much time was 'stolen' from it (when the virtual CPU was preem= pted -to perform some other work). - -3.6. hv-crash -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Provides HV_X64_MSR_CRASH_P0..HV_X64_MSR_CRASH_P5 (0x40000100..0x40000105)= and -HV_X64_MSR_CRASH_CTL (0x40000105) MSRs to the guest. These MSRs are writte= n to -by the guest when it crashes, HV_X64_MSR_CRASH_P0..HV_X64_MSR_CRASH_P5 MSRs -contain additional crash information. This information is outputted in QEM= U log -and through QAPI. -Note: unlike under genuine Hyper-V, write to HV_X64_MSR_CRASH_CTL causes g= uest -to shutdown. This effectively blocks crash dump generation by Windows. - -3.7. hv-time -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Enables two Hyper-V-specific clocksources available to the guest: MSR-based -Hyper-V clocksource (HV_X64_MSR_TIME_REF_COUNT, 0x40000020) and Reference = TSC -page (enabled via MSR HV_X64_MSR_REFERENCE_TSC, 0x40000021). Both clocksou= rces -are per-guest, Reference TSC page clocksource allows for exit-less time st= amp -readings. Using this enlightenment leads to significant speedup of all tim= estamp -related operations. - -3.8. hv-synic -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Enables Hyper-V Synthetic interrupt controller - an extension of a local A= PIC. -When enabled, this enlightenment provides additional communication facilit= ies -to the guest: SynIC messages and Events. This is a pre-requisite for -implementing VMBus devices (not yet in QEMU). Additionally, this enlighten= ment -is needed to enable Hyper-V synthetic timers. SynIC is controlled through = MSRs -HV_X64_MSR_SCONTROL..HV_X64_MSR_EOM (0x40000080..0x40000084) and -HV_X64_MSR_SINT0..HV_X64_MSR_SINT15 (0x40000090..0x4000009F) - -Requires: hv-vpindex - -3.9. hv-stimer -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Enables Hyper-V synthetic timers. There are four synthetic timers per virt= ual -CPU controlled through HV_X64_MSR_STIMER0_CONFIG..HV_X64_MSR_STIMER3_COUNT -(0x400000B0..0x400000B7) MSRs. These timers can work either in single-shot= or -periodic mode. It is known that certain Windows versions revert to using H= PET -(or even RTC when HPET is unavailable) extensively when this enlightenment= is -not provided; this can lead to significant CPU consumption, even when virt= ual -CPU is idle. - -Requires: hv-vpindex, hv-synic, hv-time - -3.10. hv-tlbflush -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Enables paravirtualized TLB shoot-down mechanism. On x86 architecture, rem= ote -TLB flush procedure requires sending IPIs and waiting for other CPUs to pe= rform -local TLB flush. In virtualized environment some virtual CPUs may not even= be -scheduled at the time of the call and may not require flushing (or, flushi= ng -may be postponed until the virtual CPU is scheduled). hv-tlbflush enlighte= nment -implements TLB shoot-down through hypervisor enabling the optimization. - -Requires: hv-vpindex - -3.11. hv-ipi -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Enables paravirtualized IPI send mechanism. HvCallSendSyntheticClusterIpi -hypercall may target more than 64 virtual CPUs simultaneously, doing the s= ame -through APIC requires more than one access (and thus exit to the hyperviso= r). - -Requires: hv-vpindex - -3.12. hv-vendor-id=3Dxxx -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -This changes Hyper-V identification in CPUID 0x40000000.EBX-EDX from the d= efault -"Microsoft Hv". The parameter should be no longer than 12 characters. Acco= rding -to the specification, guests shouldn't use this information and it is unkn= own -if there is a Windows version which acts differently. -Note: hv-vendor-id is not an enlightenment and thus doesn't enable Hyper-V -identification when specified without some other enlightenment. - -3.13. hv-reset -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Provides HV_X64_MSR_RESET (0x40000003) MSR to the guest allowing it to res= et -itself by writing to it. Even when this MSR is enabled, it is not a recomm= ended -way for Windows to perform system reboot and thus it may not be used. - -3.14. hv-frequencies -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Provides HV_X64_MSR_TSC_FREQUENCY (0x40000022) and HV_X64_MSR_APIC_FREQUEN= CY -(0x40000023) allowing the guest to get its TSC/APIC frequencies without do= ing -measurements. - -3.15 hv-reenlightenment -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -The enlightenment is nested specific, it targets Hyper-V on KVM guests. Wh= en -enabled, it provides HV_X64_MSR_REENLIGHTENMENT_CONTROL (0x40000106), -HV_X64_MSR_TSC_EMULATION_CONTROL (0x40000107)and HV_X64_MSR_TSC_EMULATION_= STATUS -(0x40000108) MSRs allowing the guest to get notified when TSC frequency ch= anges -(only happens on migration) and keep using old frequency (through emulatio= n in -the hypervisor) until it is ready to switch to the new one. This, in conju= nction -with hv-frequencies, allows Hyper-V on KVM to pass stable clocksource (Ref= erence -TSC page) to its own guests. - -Note, KVM doesn't fully support re-enlightenment notifications and doesn't -emulate TSC accesses after migration so 'tsc-frequency=3D' CPU option also= has to -be specified to make migration succeed. The destination host has to either= have -the same TSC frequency or support TSC scaling CPU feature. - -Recommended: hv-frequencies - -3.16. hv-evmcs -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -The enlightenment is nested specific, it targets Hyper-V on KVM guests. Wh= en -enabled, it provides Enlightened VMCS version 1 feature to the guest. The = feature -implements paravirtualized protocol between L0 (KVM) and L1 (Hyper-V) -hypervisors making L2 exits to the hypervisor faster. The feature is Intel= -only. -Note: some virtualization features (e.g. Posted Interrupts) are disabled w= hen -hv-evmcs is enabled. It may make sense to measure your nested workload wit= h and -without the feature to find out if enabling it is beneficial. - -Requires: hv-vapic - -3.17. hv-stimer-direct -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Hyper-V specification allows synthetic timer operation in two modes: "clas= sic", -when expiration event is delivered as SynIC message and "direct", when the= event -is delivered via normal interrupt. It is known that nested Hyper-V can only -use synthetic timers in direct mode and thus 'hv-stimer-direct' needs to be -enabled. - -Requires: hv-vpindex, hv-synic, hv-time, hv-stimer - -3.18. hv-avic (hv-apicv) -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -The enlightenment allows to use Hyper-V SynIC with hardware APICv/AVIC ena= bled. -Normally, Hyper-V SynIC disables these hardware feature and suggests the g= uest -to use paravirtualized AutoEOI feature. -Note: enabling this feature on old hardware (without APICv/AVIC support) m= ay -have negative effect on guest's performance. - -3.19. hv-no-nonarch-coresharing=3Don/off/auto -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -This enlightenment tells guest OS that virtual processors will never share= a -physical core unless they are reported as sibling SMT threads. This inform= ation -is required by Windows and Hyper-V guests to properly mitigate SMT related= CPU -vulnerabilities. -When the option is set to 'auto' QEMU will enable the feature only when KVM -reports that non-architectural coresharing is impossible, this means that -hyper-threading is not supported or completely disabled on the host. This -setting also prevents migration as SMT settings on the destination may dif= fer. -When the option is set to 'on' QEMU will always enable the feature, regard= less -of host setup. To keep guests secure, this can only be used in conjunction= with -exposing correct vCPU topology and vCPU pinning. - -3.20. hv-version-id-{build,major,minor,spack,sbranch,snumber} -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -This changes Hyper-V version identification in CPUID 0x40000002.EAX-EDX fr= om the -default (WS2016). -- hv-version-id-build sets 'Build Number' (32 bits) -- hv-version-id-major sets 'Major Version' (16 bits) -- hv-version-id-minor sets 'Minor Version' (16 bits) -- hv-version-id-spack sets 'Service Pack' (32 bits) -- hv-version-id-sbranch sets 'Service Branch' (8 bits) -- hv-version-id-snumber sets 'Service Number' (24 bits) - -Note: hv-version-id-* are not enlightenments and thus don't enable Hyper-V -identification when specified without any other enlightenments. - -3.21. hv-syndbg -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Enables Hyper-V synthetic debugger interface, this is a special interface = used -by Windows Kernel debugger to send the packets through, rather than sending -them via serial/network . -When enabled, this enlightenment provides additional communication facilit= ies -to the guest: SynDbg messages. -This new communication is used by Windows Kernel debugger rather than send= ing -packets via serial/network, adding significant performance boost over the = other -comm channels. -This enlightenment requires a VMBus device (-device vmbus-bridge,irq=3D15) -and the follow enlightenments to work: -hv-relaxed,hv_time,hv-vapic,hv-vpindex,hv-synic,hv-runtime,hv-stimer - -3.22. hv-emsr-bitmap -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -The enlightenment is nested specific, it targets Hyper-V on KVM guests. Wh= en -enabled, it allows L0 (KVM) and L1 (Hyper-V) hypervisors to collaborate to -avoid unnecessary updates to L2 MSR-Bitmap upon vmexits. While the protoco= l is -supported for both VMX (Intel) and SVM (AMD), the VMX implementation requi= res -Enlightened VMCS ('hv-evmcs') feature to also be enabled. - -Recommended: hv-evmcs (Intel) - -3.23. hv-xmm-input -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Hyper-V specification allows to pass parameters for certain hypercalls usi= ng XMM -registers ("XMM Fast Hypercall Input"). When the feature is in use, it all= ows -for faster hypercalls processing as KVM can avoid reading guest's memory. - -3.24. hv-tlbflush-ext -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Allow for extended GVA ranges to be passed to Hyper-V TLB flush hypercalls -(HvFlushVirtualAddressList/HvFlushVirtualAddressListEx). - -Requires: hv-tlbflush - -3.25. hv-tlbflush-direct -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D -The enlightenment is nested specific, it targets Hyper-V on KVM guests. Wh= en -enabled, it allows L0 (KVM) to directly handle TLB flush hypercalls from L2 -guest without the need to exit to L1 (Hyper-V) hypervisor. While the featu= re is -supported for both VMX (Intel) and SVM (AMD), the VMX implementation requi= res -Enlightened VMCS ('hv-evmcs') feature to also be enabled. - -Requires: hv-vapic -Recommended: hv-evmcs (Intel) - -4. Supplementary features -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D - -4.1. hv-passthrough -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -In some cases (e.g. during development) it may make sense to use QEMU in -'pass-through' mode and give Windows guests all enlightenments currently -supported by KVM. This pass-through mode is enabled by "hv-passthrough" CPU -flag. -Note: "hv-passthrough" flag only enables enlightenments which are known to= QEMU -(have corresponding "hv-*" flag) and copies "hv-spinlocks=3D"/"hv-vendor-i= d=3D" -values from KVM to QEMU. "hv-passthrough" overrides all other "hv-*" setti= ngs on -the command line. Also, enabling this flag effectively prevents migration = as the -list of enabled enlightenments may differ between target and destination h= osts. - -4.2. hv-enforce-cpuid -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -By default, KVM allows the guest to use all currently supported Hyper-V -enlightenments when Hyper-V CPUID interface was exposed, regardless of if -some features were not announced in guest visible CPUIDs. 'hv-enforce-cpui= d' -feature alters this behavior and only allows the guest to use exposed Hype= r-V -enlightenments. - - -5. Useful links -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Hyper-V Top Level Functional specification and other information: -https://github.com/MicrosoftDocs/Virtualization-Documentation diff --git a/docs/system/i386/hyperv.rst b/docs/system/i386/hyperv.rst new file mode 100644 index 0000000000..2505dc4c86 --- /dev/null +++ b/docs/system/i386/hyperv.rst @@ -0,0 +1,288 @@ +Hyper-V Enlightenments +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + + +Description +----------- + +In some cases when implementing a hardware interface in software is slow, = KVM +implements its own paravirtualized interfaces. This works well for Linux as +guest support for such features is added simultaneously with the feature i= tself. +It may, however, be hard-to-impossible to add support for these interfaces= to +proprietary OSes, namely, Microsoft Windows. + +KVM on x86 implements Hyper-V Enlightenments for Windows guests. These fea= tures +make Windows and Hyper-V guests think they're running on top of a Hyper-V +compatible hypervisor ants, QEMU is supposed to +check that the supplied configuration is sane. + +When any set of the Hyper-V enlightenments is enabled, QEMU changes hyperv= isor +identification (CPUID 0x40000000..0x4000000A) to Hyper-V. KVM identificati= on +and features are kept in leaves 0x40000100..0x40000101. + + +Existing enlightenments +----------------------- + +``hv-relaxed`` + This feature tells guest OS to disable watchdog timeouts as it is runnin= g on a + hypervisor. It is known that some Windows versions will do this even whe= n they + see 'hypervisor' CPU flag. + +``hv-vapic`` + Provides so-called VP Assist page MSR to guest allowing it to work with = APIC + more efficiently. In particular, this enlightenment allows paravirtualiz= ed + (exit-less) EOI processing. + +``hv-spinlocks`` =3D xxx + Enables paravirtualized spinlocks. The parameter indicates how many times + spinlock acquisition should be attempted before indicating the situation= to the + hypervisor. A special value 0xffffffff indicates "never notify". + +``hv-vpindex`` + Provides HV_X64_MSR_VP_INDEX (0x40000002) MSR to the guest which has Vir= tual + processor index information. This enlightenment makes sense in conjuncti= on with + hv-synic, hv-stimer and other enlightenments which require the guest to = know its + Virtual Processor indices (e.g. when VP index needs to be passed in a + hypercall). + +``hv-runtime`` + Provides HV_X64_MSR_VP_RUNTIME (0x40000010) MSR to the guest. The MSR ke= eps the + virtual processor run time in 100ns units. This gives guest operating sy= stem an + idea of how much time was 'stolen' from it (when the virtual CPU was pre= empted + to perform some other work). + +``hv-crash`` + Provides HV_X64_MSR_CRASH_P0..HV_X64_MSR_CRASH_P5 (0x40000100..0x4000010= 5) and + HV_X64_MSR_CRASH_CTL (0x40000105) MSRs to the guest. These MSRs are writ= ten to + by the guest when it crashes, HV_X64_MSR_CRASH_P0..HV_X64_MSR_CRASH_P5 M= SRs + contain additional crash information. This information is outputted in Q= EMU log + and through QAPI. + Note: unlike under genuine Hyper-V, write to HV_X64_MSR_CRASH_CTL causes= guest + to shutdown. This effectively blocks crash dump generation by Windows. + +``hv-time`` + Enables two Hyper-V-specific clocksources available to the guest: MSR-ba= sed + Hyper-V clocksource (HV_X64_MSR_TIME_REF_COUNT, 0x40000020) and Referenc= e TSC + page (enabled via MSR HV_X64_MSR_REFERENCE_TSC, 0x40000021). Both clocks= ources + are per-guest, Reference TSC page clocksource allows for exit-less time = stamp + readings. Using this enlightenment leads to significant speedup of all t= imestamp + related operations. + +``hv-synic`` + Enables Hyper-V Synthetic interrupt controller - an extension of a local= APIC. + When enabled, this enlightenment provides additional communication facil= ities + to the guest: SynIC messages and Events. This is a pre-requisite for + implementing VMBus devices (not yet in QEMU). Additionally, this enlight= enment + is needed to enable Hyper-V synthetic timers. SynIC is controlled throug= h MSRs + HV_X64_MSR_SCONTROL..HV_X64_MSR_EOM (0x40000080..0x40000084) and + HV_X64_MSR_SINT0..HV_X64_MSR_SINT15 (0x40000090..0x4000009F) + + Requires: ``hv-vpindex`` + +``hv-stimer`` + Enables Hyper-V synthetic timers. There are four synthetic timers per vi= rtual + CPU controlled through HV_X64_MSR_STIMER0_CONFIG..HV_X64_MSR_STIMER3_COU= NT + (0x400000B0..0x400000B7) MSRs. These timers can work either in single-sh= ot or + periodic mode. It is known that certain Windows versions revert to using= HPET + (or even RTC when HPET is unavailable) extensively when this enlightenme= nt is + not provided; this can lead to significant CPU consumption, even when vi= rtual + CPU is idle. + + Requires: ``hv-vpindex``, ``hv-synic``, ``hv-time`` + +``hv-tlbflush`` + Enables paravirtualized TLB shoot-down mechanism. On x86 architecture, r= emote + TLB flush procedure requires sending IPIs and waiting for other CPUs to = perform + local TLB flush. In virtualized environment some virtual CPUs may not ev= en be + scheduled at the time of the call and may not require flushing (or, flus= hing + may be postponed until the virtual CPU is scheduled). hv-tlbflush enligh= tenment + implements TLB shoot-down through hypervisor enabling the optimization. + + Requires: ``hv-vpindex`` + +``hv-ipi`` + Enables paravirtualized IPI send mechanism. HvCallSendSyntheticClusterIpi + hypercall may target more than 64 virtual CPUs simultaneously, doing the= same + through APIC requires more than one access (and thus exit to the hypervi= sor). + + Requires: ``hv-vpindex`` + +``hv-vendor-id`` =3D xxx + This changes Hyper-V identification in CPUID 0x40000000.EBX-EDX from the= default + "Microsoft Hv". The parameter should be no longer than 12 characters. Ac= cording + to the specification, guests shouldn't use this information and it is un= known + if there is a Windows version which acts differently. + Note: hv-vendor-id is not an enlightenment and thus doesn't enable Hyper= -V + identification when specified without some other enlightenment. + +``hv-reset`` + Provides HV_X64_MSR_RESET (0x40000003) MSR to the guest allowing it to r= eset + itself by writing to it. Even when this MSR is enabled, it is not a reco= mmended + way for Windows to perform system reboot and thus it may not be used. + +``hv-frequencies`` + Provides HV_X64_MSR_TSC_FREQUENCY (0x40000022) and HV_X64_MSR_APIC_FREQU= ENCY + (0x40000023) allowing the guest to get its TSC/APIC frequencies without = doing + measurements. + +``hv-reenlightenment`` + The enlightenment is nested specific, it targets Hyper-V on KVM guests. = When + enabled, it provides HV_X64_MSR_REENLIGHTENMENT_CONTROL (0x40000106), + HV_X64_MSR_TSC_EMULATION_CONTROL (0x40000107)and HV_X64_MSR_TSC_EMULATIO= N_STATUS + (0x40000108) MSRs allowing the guest to get notified when TSC frequency = changes + (only happens on migration) and keep using old frequency (through emulat= ion in + the hypervisor) until it is ready to switch to the new one. This, in con= junction + with ``hv-frequencies``, allows Hyper-V on KVM to pass stable clocksource + (Reference TSC page) to its own guests. + + Note, KVM doesn't fully support re-enlightenment notifications and doesn= 't + emulate TSC accesses after migration so 'tsc-frequency=3D' CPU option al= so has to + be specified to make migration succeed. The destination host has to eith= er have + the same TSC frequency or support TSC scaling CPU feature. + + Recommended: ``hv-frequencies`` + +``hv-evmcs`` + The enlightenment is nested specific, it targets Hyper-V on KVM guests. = When + enabled, it provides Enlightened VMCS version 1 feature to the guest. Th= e feature + implements paravirtualized protocol between L0 (KVM) and L1 (Hyper-V) + hypervisors making L2 exits to the hypervisor faster. The feature is Int= el-only. + + Note: some virtualization features (e.g. Posted Interrupts) are disabled= when + hv-evmcs is enabled. It may make sense to measure your nested workload w= ith and + without the feature to find out if enabling it is beneficial. + + Requires: ``hv-vapic`` + +``hv-stimer-direct`` + Hyper-V specification allows synthetic timer operation in two modes: "cl= assic", + when expiration event is delivered as SynIC message and "direct", when t= he event + is delivered via normal interrupt. It is known that nested Hyper-V can o= nly + use synthetic timers in direct mode and thus ``hv-stimer-direct`` needs = to be + enabled. + + Requires: ``hv-vpindex``, ``hv-synic``, ``hv-time``, ``hv-stimer`` + +``hv-avic`` (``hv-apicv``) + The enlightenment allows to use Hyper-V SynIC with hardware APICv/AVIC e= nabled. + Normally, Hyper-V SynIC disables these hardware feature and suggests the= guest + to use paravirtualized AutoEOI feature. + Note: enabling this feature on old hardware (without APICv/AVIC support)= may + have negative effect on guest's performance. + +``hv-no-nonarch-coresharing`` =3D on/off/auto + This enlightenment tells guest OS that virtual processors will never sha= re a + physical core unless they are reported as sibling SMT threads. This info= rmation + is required by Windows and Hyper-V guests to properly mitigate SMT relat= ed CPU + vulnerabilities. + + When the option is set to 'auto' QEMU will enable the feature only when = KVM + reports that non-architectural coresharing is impossible, this means that + hyper-threading is not supported or completely disabled on the host. This + setting also prevents migration as SMT settings on the destination may d= iffer. + When the option is set to 'on' QEMU will always enable the feature, rega= rdless + of host setup. To keep guests secure, this can only be used in conjuncti= on with + exposing correct vCPU topology and vCPU pinning. + +``hv-version-id-build``, ``hv-version-id-major``, ``hv-version-id-minor``,= ``hv-version-id-spack``, ``hv-version-id-sbranch``, ``hv-version-id-snumbe= r`` + This changes Hyper-V version identification in CPUID 0x40000002.EAX-EDX = from the + default (WS2016). + + - ``hv-version-id-build`` sets 'Build Number' (32 bits) + - ``hv-version-id-major`` sets 'Major Version' (16 bits) + - ``hv-version-id-minor`` sets 'Minor Version' (16 bits) + - ``hv-version-id-spack`` sets 'Service Pack' (32 bits) + - ``hv-version-id-sbranch`` sets 'Service Branch' (8 bits) + - ``hv-version-id-snumber`` sets 'Service Number' (24 bits) + + Note: hv-version-id-* are not enlightenments and thus don't enable Hyper= -V + identification when specified without any other enlightenments. + +``hv-syndbg`` + Enables Hyper-V synthetic debugger interface, this is a special interfac= e used + by Windows Kernel debugger to send the packets through, rather than send= ing + them via serial/network . + When enabled, this enlightenment provides additional communication facil= ities + to the guest: SynDbg messages. + This new communication is used by Windows Kernel debugger rather than se= nding + packets via serial/network, adding significant performance boost over th= e other + comm channels. + This enlightenment requires a VMBus device (-device vmbus-bridge,irq=3D1= 5). + + Requires: ``hv-relaxed``, ``hv_time``, ``hv-vapic``, ``hv-vpindex``, ``h= v-synic``, ``hv-runtime``, ``hv-stimer`` + +``hv-emsr-bitmap`` + The enlightenment is nested specific, it targets Hyper-V on KVM guests. = When + enabled, it allows L0 (KVM) and L1 (Hyper-V) hypervisors to collaborate = to + avoid unnecessary updates to L2 MSR-Bitmap upon vmexits. While the proto= col is + supported for both VMX (Intel) and SVM (AMD), the VMX implementation req= uires + Enlightened VMCS (``hv-evmcs``) feature to also be enabled. + + Recommended: ``hv-evmcs`` (Intel) + +``hv-xmm-input`` + Hyper-V specification allows to pass parameters for certain hypercalls u= sing XMM + registers ("XMM Fast Hypercall Input"). When the feature is in use, it a= llows + for faster hypercalls processing as KVM can avoid reading guest's memory. + +``hv-tlbflush-ext`` + Allow for extended GVA ranges to be passed to Hyper-V TLB flush hypercal= ls + (HvFlushVirtualAddressList/HvFlushVirtualAddressListEx). + + Requires: ``hv-tlbflush`` + +``hv-tlbflush-direct`` + The enlightenment is nested specific, it targets Hyper-V on KVM guests. = When + enabled, it allows L0 (KVM) to directly handle TLB flush hypercalls from= L2 + guest without the need to exit to L1 (Hyper-V) hypervisor. While the fea= ture is + supported for both VMX (Intel) and SVM (AMD), the VMX implementation req= uires + Enlightened VMCS (``hv-evmcs``) feature to also be enabled. + + Requires: ``hv-vapic`` + + Recommended: ``hv-evmcs`` (Intel) + +Supplementary features +---------------------- + +``hv-passthrough`` + In some cases (e.g. during development) it may make sense to use QEMU in + 'pass-through' mode and give Windows guests all enlightenments currently + supported by KVM. This pass-through mode is enabled by "hv-passthrough" = CPU + flag. + + Note: ``hv-passthrough`` flag only enables enlightenments which are know= n to QEMU + (have corresponding 'hv-' flag) and copies ``hv-spinlocks`` and ``hv-ven= dor-id`` + values from KVM to QEMU. ``hv-passthrough`` overrides all other 'hv-' se= ttings on + the command line. Also, enabling this flag effectively prevents migratio= n as the + list of enabled enlightenments may differ between target and destination= hosts. + +``hv-enforce-cpuid`` + By default, KVM allows the guest to use all currently supported Hyper-V + enlightenments when Hyper-V CPUID interface was exposed, regardless of if + some features were not announced in guest visible CPUIDs. ``hv-enforce-c= puid`` + feature alters this behavior and only allows the guest to use exposed Hy= per-V + enlightenments. + + +Useful links +------------ +Hyper-V Top Level Functional specification and other information: + +- https://github.com/MicrosoftDocs/Virtualization-Documentation +- https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/tlfs/= tlfs + diff --git a/docs/system/target-i386.rst b/docs/system/target-i386.rst index 96bf54889a..e64c013077 100644 --- a/docs/system/target-i386.rst +++ b/docs/system/target-i386.rst @@ -26,6 +26,7 @@ Architectural features :maxdepth: 1 =20 i386/cpu + i386/hyperv i386/kvm-pv i386/sgx i386/amd-memory-encryption --=20 2.36.1