From nobody Mon May 6 06:27:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541541406255795.9213588067731; Tue, 6 Nov 2018 13:56:46 -0800 (PST) Received: from localhost ([::1]:43954 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9Kv-0006UW-KP for importer@patchew.org; Tue, 06 Nov 2018 16:56:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40129) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9Cr-0002l6-Do for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:48:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK93V-0001OE-WF for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:41 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:36807) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK93V-0008JR-42 for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:37 -0500 Received: by mail-wm1-x332.google.com with SMTP id a8-v6so13741234wmf.1 for ; Tue, 06 Nov 2018 13:38:07 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id l186-v6sm3223526wma.13.2018.11.06.13.38.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:38:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Z2dLXAjqPsYiDE2KG3TA3x3OxiKYmk9EUCnKtZXwwok=; b=uR38xXc2FCafwcRWuISNhyg41/cNeFPowOGOLpKatrxv1LT8qRIKOQcklOgOG8iPaK bsrwtffvPhZv5dDednAntqJrf7y6274/jRuqVcEatr1GQOG7dqGYEIm+63hphAn1JAK0 NAOvGQLuma3jDYmX9uzR/ndb2SdtYS1ayQ5vuh3meoi4uZNfYzAJbUvGqMFOe912M7ic FQH5MxL1K9m7xdfcQDilvKipnvmIn7eglqVsMlgK80p7wCAUIx1GBeMlejx5Mmd+b0dh Q5E5mIPdyVhfi//5zWhxF96QLcTi5oDCPYULt9XcZyl5FS1a+3PaDVrhhMWNdk7AqBYY MV0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Z2dLXAjqPsYiDE2KG3TA3x3OxiKYmk9EUCnKtZXwwok=; b=PC6nPSYSyUDwx3oqBmVB+VE7urfFY4KhJp6ZC7pjzgwBuULzXwbbXHX7k8qvIJNm8Z umJt1eAUf/Bz2M+93mg+boLypG/yLrCaYOEHAwy7aFzDe/sJRA/Vd8T9F0IJm14YeVre ubDQHFqXXGzS6xOmvhnG3ZAW980dnXasame6BpQ6omso2hBQO0FneWY0IRH6IgBy2UTW sHhaUuLS6SUaDswQ23xBe5iTWvqOywNfQyxAgg65Nb2N5fcnLnjEnZ4q/U0XtVtIV5w4 6UxqX/eBKU5S+d4jPCwR/I5UtBRyhMfS65JgfzzsvNTpnioprQp9Lmk3PwDixyVfaBOm bxyA== X-Gm-Message-State: AGRZ1gIHQFVyu2w7POJi1S2m7pKxrBYcxdiTcXOEJ1TMk10q7vMNfzr4 IXRs1jZV/ezEOcVs9uwpYJyoc9tK X-Google-Smtp-Source: AJdET5emQIRB1D5jfdJcUsgVwnVsKujhye0u+e4Okfu9BJfA388Ptx5QJuh2MCacvx5qOpZQHEKv3Q== X-Received: by 2002:a1c:84:: with SMTP id 126-v6mr3227036wma.96.1541540286607; Tue, 06 Nov 2018 13:38:06 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 22:37:47 +0100 Message-Id: <1541540283-45699-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> References: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 Subject: [Qemu-devel] [PULL 01/17] icount: fix deadlock when all cpus are sleeping X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Clement Deschamps Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Clement Deschamps When all cpus are sleeping (e.g in WFI), to avoid a deadlock in the main_loop, wake it up in order to start the warp timer. Signed-off-by: Clement Deschamps Message-Id: <20181021142103.19014-1-clement.deschamps@greensocs.com> Signed-off-by: Paolo Bonzini --- cpus.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cpus.c b/cpus.c index 3978f63..a2b33cc 100644 --- a/cpus.c +++ b/cpus.c @@ -1554,6 +1554,14 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg) atomic_mb_set(&cpu->exit_request, 0); } =20 + if (use_icount && all_cpu_threads_idle()) { + /* + * When all cpus are sleeping (e.g in WFI), to avoid a deadlock + * in the main_loop, wake it up in order to start the warp tim= er. + */ + qemu_notify_event(); + } + qemu_tcg_rr_wait_io_event(cpu ? cpu : first_cpu); deal_with_unplugged_cpus(); } --=20 1.8.3.1 From nobody Mon May 6 06:27:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541541235071254.3548292312911; Tue, 6 Nov 2018 13:53:55 -0800 (PST) Received: from localhost ([::1]:43933 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9I5-0003Vo-Kn for importer@patchew.org; Tue, 06 Nov 2018 16:53:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9Cq-0003Lq-LC for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:48:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK93W-0001PB-60 for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:42 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:45471) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK93V-0008M7-Af for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:37 -0500 Received: by mail-wr1-x431.google.com with SMTP id k15-v6so12228472wre.12 for ; Tue, 06 Nov 2018 13:38:08 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id l186-v6sm3223526wma.13.2018.11.06.13.38.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:38:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=JLTKVYa23zlWfgJjqL8K3WJSasc3+i7/ymtVsVFHHvI=; b=HtcMdFCRReGokPsl+sszRd98vuVlV97FK9MvD9elXUCWHyoNdziRP2qcyt+hV0pqIH zEIFpwaULPX3OgPmbSFLMECtdokyInB9k6XdV++RB6ADABXuN144nHdngwdXzHa9oExk RbBUrdVVbgh7R2hnQTKY8QbkANrVhRYWSjwv1uyao+7YD+hiFHf168cO1M4QAWeFcBM/ eB57QmDCJon05tHX1jWbA0LsMpMvbM1fYUU0LOwlaP+qhrHvwGLXi+4/tQ+AdT5QhvYJ K1GYD9ce4KDhe6Dg1y0aZykzv+FnBia+78G2P624bIZop6VpWSpNanfpBXR8BlWyhZRu Y95Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=JLTKVYa23zlWfgJjqL8K3WJSasc3+i7/ymtVsVFHHvI=; b=pxTjf0BXlUtb6MZ8ugLL2FwiP1I35phrsP+tAY+2kwYslZGC3Mq50jYtMYXM+uDRmb WCWOS/TttRaaU1YQk4hvfIydtxa1adsyCHwbmNfheA4CeURK6kQNi+SRJ+i3z7yB9r+V bemMaCagvroKYMCrvcJhigE1FOPdyTevAFY19TERg0aXB8KEwPGcBUxD8tQtT8FGIl2A 4wIz3S/D5cCJOx1mZxh119ybWIaLy5zO1lwDjK3rWdlVHKxkIcRTOAZbK57eDOQ2IDob HDnG7OowcTL3uCb0Qqb8ESNBNEImmfqGgefkm5Si6byl76nWgGomrOln7DMyI6iyShXq OCww== X-Gm-Message-State: AGRZ1gLWAY1z36p0xxK2ibzD9KsZ11nvBvaxbGkmP1PgJAiussxDbLdR Tg+d37+U4m+tmfu3zdp+vxZqODVb X-Google-Smtp-Source: AJdET5c+6pr9t5g20Vksfe2XYngcRsGHFksSBSJ6C26WFTIm1QXFFYbVg66rtxn7Mw0IHhO5eT4ESg== X-Received: by 2002:adf:8425:: with SMTP id 34-v6mr23185384wrf.153.1541540287692; Tue, 06 Nov 2018 13:38:07 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 22:37:48 +0100 Message-Id: <1541540283-45699-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> References: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::431 Subject: [Qemu-devel] [PULL 02/17] x86: hv_evmcs CPU flag support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vitaly Kuznetsov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov Adds a new CPU flag to enable the Enlightened VMCS KVM feature. QEMU enables KVM_CAP_HYPERV_ENLIGHTENED_VMCS and gets back the version to be advertised in lower 16 bits of CPUID.0x4000000A:EAX. Suggested-by: Ladi Prosek Signed-off-by: Vitaly Kuznetsov Message-Id: <20181022165506.30332-3-vkuznets@redhat.com> Reviewed-by: Roman Kagan Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target/i386/hyperv-proto.h | 2 ++ target/i386/kvm.c | 30 ++++++++++++++++++++++++++++-- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index af7e9f0..f81d35e 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5732,6 +5732,7 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_BOOL("hv-frequencies", X86CPU, hyperv_frequencies, false), DEFINE_PROP_BOOL("hv-reenlightenment", X86CPU, hyperv_reenlightenment,= false), DEFINE_PROP_BOOL("hv-tlbflush", X86CPU, hyperv_tlbflush, false), + DEFINE_PROP_BOOL("hv-evmcs", X86CPU, hyperv_evmcs, false), DEFINE_PROP_BOOL("hv-ipi", X86CPU, hyperv_ipi, false), DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, true), DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false), diff --git a/target/i386/cpu.h b/target/i386/cpu.h index ad0e0b4..9c52d0c 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1391,6 +1391,7 @@ struct X86CPU { bool hyperv_frequencies; bool hyperv_reenlightenment; bool hyperv_tlbflush; + bool hyperv_evmcs; bool hyperv_ipi; bool check_cpuid; bool enforce_cpuid; diff --git a/target/i386/hyperv-proto.h b/target/i386/hyperv-proto.h index 8c572cd..c0272b3 100644 --- a/target/i386/hyperv-proto.h +++ b/target/i386/hyperv-proto.h @@ -18,6 +18,7 @@ #define HV_CPUID_FEATURES 0x40000003 #define HV_CPUID_ENLIGHTMENT_INFO 0x40000004 #define HV_CPUID_IMPLEMENT_LIMITS 0x40000005 +#define HV_CPUID_NESTED_FEATURES 0x4000000A #define HV_CPUID_MIN 0x40000005 #define HV_CPUID_MAX 0x4000ffff #define HV_HYPERVISOR_PRESENT_BIT 0x80000000 @@ -60,6 +61,7 @@ #define HV_RELAXED_TIMING_RECOMMENDED (1u << 5) #define HV_CLUSTER_IPI_RECOMMENDED (1u << 10) #define HV_EX_PROCESSOR_MASKS_RECOMMENDED (1u << 11) +#define HV_ENLIGHTENED_VMCS_RECOMMENDED (1u << 14) =20 /* * Basic virtualized MSRs diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 796a049..f524e7d 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -869,6 +869,7 @@ int kvm_arch_init_vcpu(CPUState *cs) uint32_t unused; struct kvm_cpuid_entry2 *c; uint32_t signature[3]; + uint16_t evmcs_version; int kvm_base =3D KVM_CPUID_SIGNATURE; int r; Error *local_err =3D NULL; @@ -912,7 +913,8 @@ int kvm_arch_init_vcpu(CPUState *cs) memset(signature, 0, 12); memcpy(signature, cpu->hyperv_vendor_id, len); } - c->eax =3D HV_CPUID_MIN; + c->eax =3D cpu->hyperv_evmcs ? + HV_CPUID_NESTED_FEATURES : HV_CPUID_IMPLEMENT_LIMITS; c->ebx =3D signature[0]; c->ecx =3D signature[1]; c->edx =3D signature[2]; @@ -970,7 +972,16 @@ int kvm_arch_init_vcpu(CPUState *cs) c->eax |=3D HV_CLUSTER_IPI_RECOMMENDED; c->eax |=3D HV_EX_PROCESSOR_MASKS_RECOMMENDED; } - + if (cpu->hyperv_evmcs) { + if (kvm_vcpu_enable_cap(cs, KVM_CAP_HYPERV_ENLIGHTENED_VMCS, 0, + (uintptr_t)&evmcs_version)) { + fprintf(stderr, "Hyper-V Enlightened VMCS " + "(requested by 'hv-evmcs' cpu flag) " + "is not supported by kernel\n"); + return -ENOSYS; + } + c->eax |=3D HV_ENLIGHTENED_VMCS_RECOMMENDED; + } c->ebx =3D cpu->hyperv_spinlock_attempts; =20 c =3D &cpuid_data.entries[cpuid_i++]; @@ -981,6 +992,21 @@ int kvm_arch_init_vcpu(CPUState *cs) =20 kvm_base =3D KVM_CPUID_SIGNATURE_NEXT; has_msr_hv_hypercall =3D true; + + if (cpu->hyperv_evmcs) { + __u32 function; + + /* Create zeroed 0x40000006..0x40000009 leaves */ + for (function =3D HV_CPUID_IMPLEMENT_LIMITS + 1; + function < HV_CPUID_NESTED_FEATURES; function++) { + c =3D &cpuid_data.entries[cpuid_i++]; + c->function =3D function; + } + + c =3D &cpuid_data.entries[cpuid_i++]; + c->function =3D HV_CPUID_NESTED_FEATURES; + c->eax =3D evmcs_version; + } } =20 if (cpu->expose_kvm) { --=20 1.8.3.1 From nobody Mon May 6 06:27:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15415408600591016.6219119682279; Tue, 6 Nov 2018 13:47:40 -0800 (PST) Received: from localhost ([::1]:43696 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9Bv-0003KN-TH for importer@patchew.org; Tue, 06 Nov 2018 16:47:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9AY-0002l5-Kk for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:45:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK93Q-00013Z-TR for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:36 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:34530) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK93Q-0008PW-II for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:32 -0500 Received: by mail-wr1-x42f.google.com with SMTP id j26-v6so15233951wre.1 for ; Tue, 06 Nov 2018 13:38:10 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id l186-v6sm3223526wma.13.2018.11.06.13.38.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:38:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9HYY6/frCL/M/wh/nFcqpefqwQl2TVl6JVxcwWo5SQw=; b=SQciCpqTBARFDwlC1wMpnJS0ngP2wK6Y06aMr6TdSMpmIUFTVI1DBzIhwveF8iWYxe kcJGUncSlOyTwBfVjPMYJB5KApU1K+7Zs3UDt04A6UEsVoptam/S49laZbqP9DlwC6Ja 4OTuDuAt02bQXK4DrFPpnOsRiBk5M8HUztWrEOfRZhr9FxVO2G/+HJJJP18YU0OsRTyQ HcDzSIK6QlxnL0b3mySzlj4X45yKE7HSOLol5xh1eS6xrgLXIb4OVzPJ1atBJSv/JXa9 0tc1gTNGPsN+NbukFbC0FE/zTffnK36xMHdUARyhAxpvqemKrI/V3Zc4nGlWA15PCdv4 EXTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=9HYY6/frCL/M/wh/nFcqpefqwQl2TVl6JVxcwWo5SQw=; b=d2OlLGtfZZuJ1uST4BsCSNYcK/E3bkxHyZ0ivTNrY2je6SBHFHZ7UzsFd4PDPqA6OT 1WuwgFilvAACVGTIomGPQf7RH4OUIh95LbhDlsBqkQtbbzRdCjTLmWvxhLckQKdLML/h YfbXi5ksOi9tWXOg0egsPTDLE3hnERtLEDbDvXjumDaH4/BfD6a5B06tdukHGaGuwcSf 3BsQnPrIFTQm6BQLixH57Fh3VzfzEhYFbNTUr8PD9jP9GYjLS4iUAr9hBA4cpQi6uT08 2qCZz7mfzWGfFUuuKtw+vIlvIEaV6hdvg1Q/0FdOZ7TojZ92BeT4oM8o18Bt6omnXrQq Rupg== X-Gm-Message-State: AGRZ1gK50dUsy5onsuwdE3U6xo4ydocJjOqXxrhWvOJUDh4F0YID+t7E HY8kalc0GofujXJfkYOYMmNn8Syh X-Google-Smtp-Source: AJdET5f1UnxNAAkKcEW0Rcf5xhX2Wx0+LiDrWxZdMTyMjRUtRausLE6+n7oMogmLbOPQl+OeYdiqYg== X-Received: by 2002:adf:f787:: with SMTP id q7-v6mr27153938wrp.9.1541540288961; Tue, 06 Nov 2018 13:38:08 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 22:37:49 +0100 Message-Id: <1541540283-45699-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> References: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42f Subject: [Qemu-devel] [PULL 03/17] i386: clarify that the Q35 machine type implements a P35 chipset X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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: fail (Header signature does not verify) From: Daniel P. Berrang=C3=A9 The 'q35' machine type implements an Intel Series 3 chipset, of which there are several variants: https://www.intel.com/Assets/PDF/datasheet/316966.pdf The key difference between the 82P35 MCH ('p35', PCI device ID 0x29c0) and 82Q35 GMCH ('q35', PCI device ID 0x29b0) variants is that the latter has an integrated graphics adapter. QEMU does not implement integrated graphics, so uses the PCI ID for the 82P35 chipset, despite calling the machine type 'q35'. Thus we rename the PCI device ID constant to reflect reality, to avoid confusing future developers. The new name more closely matches what pci.ids reports it to be: $ grep P35 /usr/share/hwdata/pci.ids | grep 29 29c0 82G33/G31/P35/P31 Express DRAM Controller 29c1 82G33/G31/P35/P31 Express PCI Express Root Port 29c4 82G33/G31/P35/P31 Express MEI Controller 29c5 82G33/G31/P35/P31 Express MEI Controller 29c6 82G33/G31/P35/P31 Express PT IDER Controller 29c7 82G33/G31/P35/P31 Express Serial KT Controller $ grep Q35 /usr/share/hwdata/pci.ids | grep 29 29b0 82Q35 Express DRAM Controller 29b1 82Q35 Express PCI Express Root Port 29b2 82Q35 Express Integrated Graphics Controller 29b3 82Q35 Express Integrated Graphics Controller 29b4 82Q35 Express MEI Controller 29b5 82Q35 Express MEI Controller 29b6 82Q35 Express PT IDER Controller 29b7 82Q35 Express Serial KT Controller Arguably the QEMU machine type should be named 'p35'. At this point in time, however, it is not worth the churn for management applications & documentation to worry about renaming it. Signed-off-by: Daniel P. Berrang=C3=A9 Message-Id: <20180830105757.10577-1-berrange@redhat.com> Signed-off-by: Paolo Bonzini --- hw/pci-host/q35.c | 10 +++++++++- include/hw/pci/pci_ids.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index 966a7cf..71e4ca5 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -622,7 +622,15 @@ static void mch_class_init(ObjectClass *klass, void *d= ata) dc->desc =3D "Host bridge"; dc->vmsd =3D &vmstate_mch; k->vendor_id =3D PCI_VENDOR_ID_INTEL; - k->device_id =3D PCI_DEVICE_ID_INTEL_Q35_MCH; + /* + * The 'q35' machine type implements an Intel Series 3 chipset, + * of which there are several variants. The key difference between + * the 82P35 MCH ('p35') and 82Q35 GMCH ('q35') variants is that + * the latter has an integrated graphics adapter. QEMU does not + * implement integrated graphics, so uses the PCI ID for the 82P35 + * chipset. + */ + k->device_id =3D PCI_DEVICE_ID_INTEL_P35_MCH; k->revision =3D MCH_HOST_BRIDGE_REVISION_DEFAULT; k->class_id =3D PCI_CLASS_BRIDGE_HOST; /* diff --git a/include/hw/pci/pci_ids.h b/include/hw/pci/pci_ids.h index 63acc72..eeb3301 100644 --- a/include/hw/pci/pci_ids.h +++ b/include/hw/pci/pci_ids.h @@ -255,7 +255,7 @@ #define PCI_DEVICE_ID_INTEL_82801I_EHCI2 0x293c #define PCI_DEVICE_ID_INTEL_82599_SFP_VF 0x10ed =20 -#define PCI_DEVICE_ID_INTEL_Q35_MCH 0x29c0 +#define PCI_DEVICE_ID_INTEL_P35_MCH 0x29c0 =20 #define PCI_VENDOR_ID_XEN 0x5853 #define PCI_DEVICE_ID_XEN_PLATFORM 0x0001 --=20 1.8.3.1 From nobody Mon May 6 06:27:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541541603781440.0372426214798; Tue, 6 Nov 2018 14:00:03 -0800 (PST) Received: from localhost ([::1]:44017 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9OE-0002ys-Gc for importer@patchew.org; Tue, 06 Nov 2018 17:00:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9DA-0003Gl-Gz for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:48:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK93T-0001EW-PY for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:38 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:39578) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK93S-0008UA-On for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:35 -0500 Received: by mail-wr1-x42c.google.com with SMTP id r10-v6so15200648wrv.6 for ; Tue, 06 Nov 2018 13:38:11 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id l186-v6sm3223526wma.13.2018.11.06.13.38.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:38:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fi1yWH9NTKCkK3qK9Cf+yLSxzs7XxZdGgTo4zMVt76A=; b=hiCFB69p3Qxgj8c9lXniUe6g7Zii4fZVP3uOGa1zKSXGP6/5a0qawCHlEb8QsmVZM4 0E9NpPUIa3WN3cyzP1BiarvkerJAEn7QP/gezOwrOR/E4xjUbXSfKBBq0wiRlJ6oMDWw Hpbl7FGGNPcGjWRKNWx33GC5h11l6AX219geLH58X4jl04qac4wF8dQr9JhHP21Mrhyg c8bHl7S3NAbeHwehkU3P0SVRTYR6YcIRG5ZTmSHZAdiImvC5UTgjLLoDVxzYvmkLy6su vUxGhB3VlL+JSducDm76mWvTku5HhcU/3zYxj16+gu2NZAQBmUGOWBT+6vvX/DvduCU6 zGZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=fi1yWH9NTKCkK3qK9Cf+yLSxzs7XxZdGgTo4zMVt76A=; b=b4DDo/P+6LS5tyWFK4QiwMYQKkZS4Xqg2wcJfgEo5kow0uRU1FimlEso47R7Fn8gKd 4QPMSoZGOu40im5uBtZp03dDGPK2lq3PRXxi7sZ5gxHkxpGGFB0iBhDnEJAZnw5zDCm0 oCq8eyzSiFhlgdyeCjFdOFqSuRpWRRQ7a8I8nTmUxRBIho1ZAJNdvL9YVVj6ZBRwmDQy Dl54bpYtA7jcrNEfu9+/6IGsXNBvoqZcwI/oLkFFEpoUbyOIaukNUVyterk8PULQTpO5 NT5YjxKMJkc3k9vHwY+pQU83wiq+vtE5NzUj97uIl0YTBggb16JdGAqqI1Y0WN8qmgNh fL3g== X-Gm-Message-State: AGRZ1gJgfpE9MNCEVtm9CgaCSfR+UWhv4oCaM5FmAjVDQBRC1FbGRFeQ ga68jj2jczgUyFOuTYZpj6TKQlqT X-Google-Smtp-Source: AJdET5ebbTTS9FS5KRXZE2YHiQVdSmdyZ1IuqTB2g/3iJXil8NTlFCCi06tvmMSW5vnWTkiaWqT5/w== X-Received: by 2002:adf:f712:: with SMTP id r18-v6mr17772883wrp.166.1541540289897; Tue, 06 Nov 2018 13:38:09 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 22:37:50 +0100 Message-Id: <1541540283-45699-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> References: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42c Subject: [Qemu-devel] [PULL 04/17] ivshmem: fix memory backend leak X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Igor Mammedov object_new() returns a new backend with refcount =3D=3D 1 and then later object_property_add_child() increases refcount to 2 So when ivshmem is destroyed, the backend it has created isn't destroyed along with it as children cleanup will bring backend's refcount only to 1, which leaks backend including resources it is using. Drop the original reference from object_new() once backend is attached to its parent. Signed-off-by: Igor Mammedov Message-Id: <1541069086-167036-1-git-send-email-imammedo@redhat.com> Reviewed-by: Marc-Andr=C3=A9 Lureau Fixes: 5503e285041979dd29698ecb41729b3b22622e8d Signed-off-by: Paolo Bonzini --- hw/misc/ivshmem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index f88910e..ecfd10a 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -1279,6 +1279,7 @@ static void desugar_shm(IVShmemState *s) object_property_set_bool(obj, true, "share", &error_abort); object_property_add_child(OBJECT(s), "internal-shm-backend", obj, &error_abort); + object_unref(obj); user_creatable_complete(obj, &error_abort); s->hostmem =3D MEMORY_BACKEND(obj); } --=20 1.8.3.1 From nobody Mon May 6 06:27:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541541040028743.2904469381625; Tue, 6 Nov 2018 13:50:40 -0800 (PST) Received: from localhost ([::1]:43906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9F9-0007qj-0v for importer@patchew.org; Tue, 06 Nov 2018 16:50:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42650) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9Cm-0005UT-Ii for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:48:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK93X-0001UE-Rx for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:43 -0500 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:40401) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK93W-00006C-60 for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:39 -0500 Received: by mail-wr1-x443.google.com with SMTP id i17-v6so15202135wre.7 for ; Tue, 06 Nov 2018 13:38:12 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id l186-v6sm3223526wma.13.2018.11.06.13.38.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:38:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cfcmsFJLXL3g8eti3bFJGHtHOLqY7ouswdkfqAFEFq4=; b=DQLh5M6Pj0mX2ZYk0Z7ji3HSaFzUIgOJZhleX9GMFuvV0uwyinFyotxIx1v87rUzN1 MfR29sWtJmblRzrqL3djIi2Pync94TFH1wvIqbhJXHtXkZG9JyQY1W499AAf+hSmxD4n W5OXucAGRDiyFHqWbN8wHtgfPmrCscHb3ba1GdC3xbl93zv4cDW2PSyEhlkSCM0RUBDW 7O5GCP9a8IlZ3eE4fxrkeozkngzIYk40JVHNA0Vr2daOX4ISLDwn8QmrFbgdK4OHZmQV BupqNZJs4SVW24n5JleeXZEPEQ9+QumTtPyh+XmuS02isuVOCFb2vCanvLK0gPWPSGEP BT/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=cfcmsFJLXL3g8eti3bFJGHtHOLqY7ouswdkfqAFEFq4=; b=B5QO06oolsspFHYzntF9Q7cxXtzmoinpzTT9ZPWNVv7ECj9Z7sq9evMnMNhEKa52El UdRxRuwUvtXZ4Qz8NEIkXuNuoQPDmNAU51rENmU0xjGhhaHY4VJoeoe3HWFjBKXi9eKs bfs3P8TRveSIG1BkKhyk99HOa99rP7CQB/xuObj1YkjIt2N2Vb2ksKxeUYQ62mCX8+Jz QHvNQavoZ3hTZ6oZV1JNdDHO80rzdSpc8BP/xP7yIkos9U8FyY3wsbdciMnEZOuE+t3S 6hjM2LBWqeDk7y1gQFd51UjDAOVhq5YhpiIFx+ohy/nUhvdwdBrCkVtMamaDbyw4DB9/ Btxg== X-Gm-Message-State: AGRZ1gLt1KOEyxCb5NjmAxxvuIgY/kKxi6WEGpcaAV8EXkXthavgxX05 pmq4Vxhwkax6VWHqiQmv2KHTnj6a X-Google-Smtp-Source: AJdET5cZaFwUWh0v4uFnIkqbwFHopuB7kBoqURtWWwRZmxn7P5iBC3F9+BHI92sEqA8+YFIYHdBBqg== X-Received: by 2002:adf:a31c:: with SMTP id c28-v6mr25419960wrb.195.1541540291132; Tue, 06 Nov 2018 13:38:11 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 22:37:51 +0100 Message-Id: <1541540283-45699-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> References: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PULL 05/17] MAINTAINERS: remove or downgrade myself to reviewer from some subsystems X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Other people are doing a much better work than myself at handling some subsystems. For those files it is better if I downgrade myself to reviewer or recognize that I am not actually doing any work there. Cc: Daniel P. Berrange Cc: Gerd Hoffmann Cc: Eric Blake Cc: Thomas Huth Cc: Laurent Vivier Cc: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini --- MAINTAINERS | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 8ec2281..d411521 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -105,9 +105,9 @@ Guest CPU cores (TCG): ---------------------- Overall L: qemu-devel@nongnu.org -M: Paolo Bonzini M: Peter Crosthwaite M: Richard Henderson +R: Paolo Bonzini S: Maintained F: cpus.c F: exec.c @@ -1139,7 +1139,8 @@ F: hw/pci-host/ppce500.c F: hw/net/fsl_etsec/ =20 Character devices -M: Paolo Bonzini +M: Marc-Andr=C3=A9 Lureau +R: Paolo Bonzini S: Odd Fixes F: hw/char/ =20 @@ -1526,8 +1527,8 @@ T: git git://github.com/famz/qemu.git bitmaps T: git git://github.com/jnsnow/qemu.git bitmaps =20 Character device backends -M: Paolo Bonzini M: Marc-Andr=C3=A9 Lureau +R: Paolo Bonzini S: Maintained F: chardev/ F: include/chardev/ @@ -1760,9 +1761,9 @@ F: tests/qmp-cmd-test.c T: git git://repo.or.cz/qemu/armbru.git qapi-next =20 qtest -M: Paolo Bonzini M: Thomas Huth M: Laurent Vivier +R: Paolo Bonzini S: Maintained F: qtest.c F: tests/libqtest.* @@ -1869,7 +1870,6 @@ F: tests/test-io-* Sockets M: Daniel P. Berrange M: Gerd Hoffmann -M: Paolo Bonzini S: Maintained F: include/qemu/sockets.h F: util/qemu-sockets.c @@ -2056,13 +2056,12 @@ M: Ronnie Sahlberg M: Paolo Bonzini M: Peter Lieven L: qemu-block@nongnu.org -S: Supported +S: Odd Fixes F: block/iscsi.c F: block/iscsi-opts.c =20 Network Block Device (NBD) M: Eric Blake -M: Paolo Bonzini L: qemu-block@nongnu.org S: Maintained F: block/nbd* --=20 1.8.3.1 From nobody Mon May 6 06:27:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541541234580992.6563978333154; Tue, 6 Nov 2018 13:53:54 -0800 (PST) Received: from localhost ([::1]:43934 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9I9-0003xB-4P for importer@patchew.org; Tue, 06 Nov 2018 16:53:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9DG-0006Xt-8I for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:48:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK93S-0001BX-Te for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:36 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:46349) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK93S-00008s-8S for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:34 -0500 Received: by mail-wr1-x436.google.com with SMTP id 74-v6so15189692wrb.13 for ; Tue, 06 Nov 2018 13:38:13 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id l186-v6sm3223526wma.13.2018.11.06.13.38.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:38:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Uw0478a/NZuYiRTAYy5+GpCx7zq4hCEZS8oy5z4+WYw=; b=G3BcM1SYUReCh9RpgMTKSJN3OawSxwZve/9abj8fXbYf88n4nJwEuWkwWftmyKRs+2 17y5rAgXuJgMN0sgKL2ZQzUC/OMYikQZkr4AZ/oGujTnCRwREPUVEEdQxy+RRrt1lyal nUTlo9++r6CKKZmJz6dSvbshCndl6cVcAIaTIK3tPI41IW2Oqa/S+F8A5FDVY6lBU1Al VqKn0MY3yOGQyUN8CHB032/RjMHXJc1nGhdOuDG2yOcq13e+QWt8xugN9e7WxfYEmLvR RcxS/oe5RU5UH/X/8NcABF9SxhntZKwOPpE0EFKb9RORzQMXmV1rphRuuCL7Z8JI4IOq HpWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Uw0478a/NZuYiRTAYy5+GpCx7zq4hCEZS8oy5z4+WYw=; b=tMp8kRi7pDbsw0jnEY2t3GvkxT6ZIC8UMKr1lNRykcJ9KZnokeMQbFZfC7rIFlQ/sb fZYvsf8D9tNPVy1m68A7ECGWaLgIGYYikjHyTLMem51L+MFNeYQSscUEz3RAFwnPzpk5 G4KNPKpIVdwcFLKMeTKlFRjh4Wz1MVwZMW/Y8lfLKcz350La3SlQ9nfF9HOovJ2QesKb CQdTyjfcA5ePtszxhKdET0Ru3ayxAxLHb2Kz+zCjNUNQKeMphugTyKaqGhrFYHaABciz yKd1TpqVg+g5RzjsRKglTNbwcAzHO/ZuI9MSpAtVF4W/9yVqMAbP8o8qblOp2q++tSg9 y4gw== X-Gm-Message-State: AGRZ1gL2WZ4bNGPgNlEevjaYjztKrW9H0MAUSQqeaHMqiU3sh4m/3c7u +JxLVtagdXC8Jo8v8THr1GWBkYUY X-Google-Smtp-Source: AJdET5d5chU5Q8AqJ03R90Ju8JHiyVI8np9SUMFJnPj0MSxkQAd6/SRDRgN+aghG66iB0RgoNHH+Ow== X-Received: by 2002:adf:b593:: with SMTP id c19-v6mr26331133wre.223.1541540292158; Tue, 06 Nov 2018 13:38:12 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 22:37:52 +0100 Message-Id: <1541540283-45699-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> References: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::436 Subject: [Qemu-devel] [PULL 06/17] target/i386: Clear RF on SYSCALL instruction X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rudolf Marek , Roman Kapl Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Rudolf Marek Fix the SYSCALL instruction in 64-bit (long mode). The RF flag should be cleared in R11 as well as in the RFLAGS. Intel and AMD CPUs behave same. AMD has this documented in the APM vol 3. Signed-off-by: Roman Kapl Signed-off-by: Rudolf Marek Message-Id: <20181019122449.26387-1-rka@sysgo.com> Signed-off-by: Paolo Bonzini --- target/i386/seg_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/seg_helper.c b/target/i386/seg_helper.c index 33714bc..63e265c 100644 --- a/target/i386/seg_helper.c +++ b/target/i386/seg_helper.c @@ -991,11 +991,11 @@ void helper_syscall(CPUX86State *env, int next_eip_ad= dend) int code64; =20 env->regs[R_ECX] =3D env->eip + next_eip_addend; - env->regs[11] =3D cpu_compute_eflags(env); + env->regs[11] =3D cpu_compute_eflags(env) & ~RF_MASK; =20 code64 =3D env->hflags & HF_CS64_MASK; =20 - env->eflags &=3D ~env->fmask; + env->eflags &=3D ~(env->fmask | RF_MASK); cpu_load_eflags(env, env->eflags, 0); cpu_x86_load_seg_cache(env, R_CS, selector & 0xfffc, 0, 0xffffffff, --=20 1.8.3.1 From nobody Mon May 6 06:27:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541541812677105.58098402042299; Tue, 6 Nov 2018 14:03:32 -0800 (PST) Received: from localhost ([::1]:44168 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9Rb-00071u-Hy for importer@patchew.org; Tue, 06 Nov 2018 17:03:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9DH-0005fy-SJ for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:48:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK93S-0001AO-Iu for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:36 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:39564) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK93R-0000CB-WA for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:34 -0500 Received: by mail-wm1-x342.google.com with SMTP id u13-v6so13826755wmc.4 for ; Tue, 06 Nov 2018 13:38:14 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id l186-v6sm3223526wma.13.2018.11.06.13.38.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:38:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Gc1z+R5p9nu4b50hsOyd0BA3dM1YQdCwZMOFJPDkMmA=; b=V2ThXUKaaVjjDfZGrN9OKHibUtSBnksEgitTQ2fVGYOnFvBM09WzjMzgAVeQ06KBJR WQslg7l+WbfzDldwv8piifzmsHIFWuORu+DWu2N5LENynTQpXoJW/8n2uQWwWjf7DKN8 Kv3zygGLLDdQBtQ65KhpIgVN0SAoWjgsmFVBe7ZYkVxFApoRBVjNLZtxEQHk9agXsp4i +n7mZA7U0RusV/XdBbCGSSN+q4bnhVufnEIDynBD/MyOuv+f1e8x6wy9wyq2rdf5OMD1 LeR8LWXCKMeEyrwS6RGU6WStgFTNqluZrAf8NOGN9nmcO44be85ZMFJ9NKHUZC+3rhjH m65w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Gc1z+R5p9nu4b50hsOyd0BA3dM1YQdCwZMOFJPDkMmA=; b=LXpqNehv1CpbFnJaZdpBlzOGCT8isvnECs/Zs4vhwHvsYMk8+IWbC9qATr+pYc0RfI wVzIJnv0+jzDO8G6Ib6EiNOC+5sBcUQ0boVOyncztR9Yl/1fHi9NHkAxF5RHxgzbkgbM x5cBiE957RWlFgxUrkufBTdkk+GFefYz+h2y8f9jDQjV0ttF7XV/NJiKns/M0o2IYRv+ LyRF1VXYzOIwttjVxjOvloZRz9RM4rEZiBH4whR95UKNdHZlnq1rnP7CL3G1U6Yp5sUQ sUG6g9FR45qUrhpWUz9946f5nkgy5trAjqsIbPW6986J/4SypLjTGM9XkqqOQ25n4PuC SQgQ== X-Gm-Message-State: AGRZ1gKbqlDqxH1oUvlCJofNeA0mbe3z8jpvfRZVaq4zvya1fx55EqgI jSSt/7Lgu+PBV+M0FqjKIfdFChB/ X-Google-Smtp-Source: AJdET5dcn0HbB1lmThkcw4jqoV17VFhCXxlB53Ufquvq61+7VyRkNs8dvgHmSCwW3vAoD6uNm5XGFA== X-Received: by 2002:a1c:adc2:: with SMTP id w185-v6mr3330944wme.103.1541540293398; Tue, 06 Nov 2018 13:38:13 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 22:37:53 +0100 Message-Id: <1541540283-45699-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> References: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PULL 07/17] memory: learn about non-volatile memory region X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: guangrong.xiao@linux.intel.com, xiaoguangrong.eric@gmail.com, mst@redhat.com, dgilbert@redhat.com, imammedo@redhat.com, pbonzini@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marc-Andr=C3=A9 Lureau Add a new flag to mark memory region that are used as non-volatile, by NVDIMM for example. That bit is propagated down to the flat view, and reflected in HMP info mtree with a "nv-" prefix on the memory type. This way, guest_phys_blocks_region_add() can skip the NV memory regions for dumps and TCG memory clear in a following patch. Cc: dgilbert@redhat.com Cc: imammedo@redhat.com Cc: pbonzini@redhat.com Cc: guangrong.xiao@linux.intel.com Cc: mst@redhat.com Cc: xiaoguangrong.eric@gmail.com Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20181003114454.5662-2-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- docs/devel/migration.rst | 1 + include/exec/memory.h | 25 +++++++++++++++++++++++++ memory.c | 45 +++++++++++++++++++++++++++++++++++---------- 3 files changed, 61 insertions(+), 10 deletions(-) diff --git a/docs/devel/migration.rst b/docs/devel/migration.rst index 6875707..e7658ab 100644 --- a/docs/devel/migration.rst +++ b/docs/devel/migration.rst @@ -435,6 +435,7 @@ Examples of such memory API functions are: - memory_region_add_subregion() - memory_region_del_subregion() - memory_region_set_readonly() + - memory_region_set_nonvolatile() - memory_region_set_enabled() - memory_region_set_address() - memory_region_set_alias_offset() diff --git a/include/exec/memory.h b/include/exec/memory.h index d0c7f0d..8e61450 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -355,6 +355,7 @@ struct MemoryRegion { bool ram; bool subpage; bool readonly; /* For RAM regions */ + bool nonvolatile; bool rom_device; bool flush_coalesced_mmio; bool global_locking; @@ -480,6 +481,7 @@ static inline FlatView *address_space_to_flatview(Addre= ssSpace *as) * @offset_within_address_space: the address of the first byte of the sect= ion * relative to the region's address space * @readonly: writes to this section are ignored + * @nonvolatile: this section is non-volatile */ struct MemoryRegionSection { MemoryRegion *mr; @@ -488,6 +490,7 @@ struct MemoryRegionSection { Int128 size; hwaddr offset_within_address_space; bool readonly; + bool nonvolatile; }; =20 /** @@ -1170,6 +1173,17 @@ static inline bool memory_region_is_rom(MemoryRegion= *mr) return mr->ram && mr->readonly; } =20 +/** + * memory_region_is_nonvolatile: check whether a memory region is non-vola= tile + * + * Returns %true is a memory region is non-volatile memory. + * + * @mr: the memory region being queried + */ +static inline bool memory_region_is_nonvolatile(MemoryRegion *mr) +{ + return mr->nonvolatile; +} =20 /** * memory_region_get_fd: Get a file descriptor backing a RAM memory region. @@ -1342,6 +1356,17 @@ void memory_region_reset_dirty(MemoryRegion *mr, hwa= ddr addr, void memory_region_set_readonly(MemoryRegion *mr, bool readonly); =20 /** + * memory_region_set_nonvolatile: Turn a memory region non-volatile + * + * Allows a memory region to be marked as non-volatile. + * only useful on RAM regions. + * + * @mr: the region being updated. + * @nonvolatile: whether rhe region is to be non-volatile. + */ +void memory_region_set_nonvolatile(MemoryRegion *mr, bool nonvolatile); + +/** * memory_region_rom_device_set_romd: enable/disable ROMD mode * * Allows a ROM device (initialized with memory_region_init_rom_device() to diff --git a/memory.c b/memory.c index 51204aa..d14c6de 100644 --- a/memory.c +++ b/memory.c @@ -216,6 +216,7 @@ struct FlatRange { uint8_t dirty_log_mask; bool romd_mode; bool readonly; + bool nonvolatile; }; =20 #define FOR_EACH_FLAT_RANGE(var, view) \ @@ -231,6 +232,7 @@ section_from_flat_range(FlatRange *fr, FlatView *fv) .size =3D fr->addr.size, .offset_within_address_space =3D int128_get64(fr->addr.start), .readonly =3D fr->readonly, + .nonvolatile =3D fr->nonvolatile, }; } =20 @@ -240,7 +242,8 @@ static bool flatrange_equal(FlatRange *a, FlatRange *b) && addrrange_equal(a->addr, b->addr) && a->offset_in_region =3D=3D b->offset_in_region && a->romd_mode =3D=3D b->romd_mode - && a->readonly =3D=3D b->readonly; + && a->readonly =3D=3D b->readonly + && a->nonvolatile =3D=3D b->nonvolatile; } =20 static FlatView *flatview_new(MemoryRegion *mr_root) @@ -312,7 +315,8 @@ static bool can_merge(FlatRange *r1, FlatRange *r2) int128_make64(r2->offset_in_region)) && r1->dirty_log_mask =3D=3D r2->dirty_log_mask && r1->romd_mode =3D=3D r2->romd_mode - && r1->readonly =3D=3D r2->readonly; + && r1->readonly =3D=3D r2->readonly + && r1->nonvolatile =3D=3D r2->nonvolatile; } =20 /* Attempt to simplify a view by merging adjacent ranges */ @@ -592,7 +596,8 @@ static void render_memory_region(FlatView *view, MemoryRegion *mr, Int128 base, AddrRange clip, - bool readonly) + bool readonly, + bool nonvolatile) { MemoryRegion *subregion; unsigned i; @@ -608,6 +613,7 @@ static void render_memory_region(FlatView *view, =20 int128_addto(&base, int128_make64(mr->addr)); readonly |=3D mr->readonly; + nonvolatile |=3D mr->nonvolatile; =20 tmp =3D addrrange_make(base, mr->size); =20 @@ -620,13 +626,15 @@ static void render_memory_region(FlatView *view, if (mr->alias) { int128_subfrom(&base, int128_make64(mr->alias->addr)); int128_subfrom(&base, int128_make64(mr->alias_offset)); - render_memory_region(view, mr->alias, base, clip, readonly); + render_memory_region(view, mr->alias, base, clip, + readonly, nonvolatile); return; } =20 /* Render subregions in priority order. */ QTAILQ_FOREACH(subregion, &mr->subregions, subregions_link) { - render_memory_region(view, subregion, base, clip, readonly); + render_memory_region(view, subregion, base, clip, + readonly, nonvolatile); } =20 if (!mr->terminates) { @@ -641,6 +649,7 @@ static void render_memory_region(FlatView *view, fr.dirty_log_mask =3D memory_region_get_dirty_log_mask(mr); fr.romd_mode =3D mr->romd_mode; fr.readonly =3D readonly; + fr.nonvolatile =3D nonvolatile; =20 /* Render the region itself into any gaps left by the current view. */ for (i =3D 0; i < view->nr && int128_nz(remain); ++i) { @@ -726,7 +735,8 @@ static FlatView *generate_memory_topology(MemoryRegion = *mr) =20 if (mr) { render_memory_region(view, mr, int128_zero(), - addrrange_make(int128_zero(), int128_2_64()),= false); + addrrange_make(int128_zero(), int128_2_64()), + false, false); } flatview_simplify(view); =20 @@ -2039,6 +2049,16 @@ void memory_region_set_readonly(MemoryRegion *mr, bo= ol readonly) } } =20 +void memory_region_set_nonvolatile(MemoryRegion *mr, bool nonvolatile) +{ + if (mr->nonvolatile !=3D nonvolatile) { + memory_region_transaction_begin(); + mr->nonvolatile =3D nonvolatile; + memory_region_update_pending |=3D mr->enabled; + memory_region_transaction_commit(); + } +} + void memory_region_rom_device_set_romd(MemoryRegion *mr, bool romd_mode) { if (mr->romd_mode !=3D romd_mode) { @@ -2489,6 +2509,7 @@ static MemoryRegionSection memory_region_find_rcu(Mem= oryRegion *mr, ret.size =3D range.size; ret.offset_within_address_space =3D int128_get64(range.start); ret.readonly =3D fr->readonly; + ret.nonvolatile =3D fr->nonvolatile; return ret; } =20 @@ -2839,10 +2860,11 @@ static void mtree_print_mr(fprintf_function mon_pri= ntf, void *f, QTAILQ_INSERT_TAIL(alias_print_queue, ml, mrqueue); } mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx - " (prio %d, %s): alias %s @%s " TARGET_FMT_plx + " (prio %d, %s%s): alias %s @%s " TARGET_FMT_plx "-" TARGET_FMT_plx "%s", cur_start, cur_end, mr->priority, + mr->nonvolatile ? "nv-" : "", memory_region_type((MemoryRegion *)mr), memory_region_name(mr), memory_region_name(mr->alias), @@ -2854,9 +2876,10 @@ static void mtree_print_mr(fprintf_function mon_prin= tf, void *f, } } else { mon_printf(f, - TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s): %s%s= ", + TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s%s): %s= %s", cur_start, cur_end, mr->priority, + mr->nonvolatile ? "nv-" : "", memory_region_type((MemoryRegion *)mr), memory_region_name(mr), mr->enabled ? "" : " [disabled]"); @@ -2941,19 +2964,21 @@ static void mtree_print_flatview(gpointer key, gpoi= nter value, mr =3D range->mr; if (range->offset_in_region) { p(f, MTREE_INDENT TARGET_FMT_plx "-" - TARGET_FMT_plx " (prio %d, %s): %s @" TARGET_FMT_plx, + TARGET_FMT_plx " (prio %d, %s%s): %s @" TARGET_FMT_plx, int128_get64(range->addr.start), int128_get64(range->addr.start) + MR_SIZE(range->addr.size), mr->priority, + range->nonvolatile ? "nv-" : "", range->readonly ? "rom" : memory_region_type(mr), memory_region_name(mr), range->offset_in_region); } else { p(f, MTREE_INDENT TARGET_FMT_plx "-" - TARGET_FMT_plx " (prio %d, %s): %s", + TARGET_FMT_plx " (prio %d, %s%s): %s", int128_get64(range->addr.start), int128_get64(range->addr.start) + MR_SIZE(range->addr.size), mr->priority, + range->nonvolatile ? "nv-" : "", range->readonly ? "rom" : memory_region_type(mr), memory_region_name(mr)); } --=20 1.8.3.1 From nobody Mon May 6 06:27:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15415417585531003.8864642053287; Tue, 6 Nov 2018 14:02:38 -0800 (PST) Received: from localhost ([::1]:44150 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9Qg-0004xD-5C for importer@patchew.org; Tue, 06 Nov 2018 17:02:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9DG-0002l5-KG for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:48:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK93S-0001Ad-Le for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:36 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:53654) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK93S-0000Fw-2f for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:34 -0500 Received: by mail-wm1-x343.google.com with SMTP id f10-v6so85575wme.3 for ; Tue, 06 Nov 2018 13:38:16 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id l186-v6sm3223526wma.13.2018.11.06.13.38.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:38:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MdH4CUsSXr7c+5WZOlEzQf04rUj140TZnFmaZO/nswQ=; b=E6l0Q/+gMFKbYoR8QLJ5MZjt2p78DxeUeJK0/iDU3gT93114gc5ZDdK3/mRRy1NofZ ovxbC2bXMI6x2oqhVgVMCIzYFhD+kNeScm412mtztaokATvfpujddwtcEq0erX/ByJWQ 5Zz72yQIEdHAyLo3Zi3ckgmOsJehsgtxneoYy203iSikYCfWiMVki0lJzk5oYFZXMKKf D3CRWGexO7Qs+CgrmLx3e2eAqwgq4aHgCwT/b53S2ZjQqVAqVI/zUrcdz6P56nNDIinM VGgmWnJo/P0jTlq86MLky4eKZORBnWGJFT2jZZuXXuaOXl1g8ImJNuTomFUa0l7TMqGR MlGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=MdH4CUsSXr7c+5WZOlEzQf04rUj140TZnFmaZO/nswQ=; b=Z0ciwzHDzNv2zDYlV6ZL2Duwa1W+2hCCTqhd2jWI5oH8jgUo/HJIqaxZGZjIMixSQW QYDpVB6gXVDunU6DwTJsv9wSNnwauGYPR4uYPRcfRM3g/632blz39T2cg/bjqiA0VWQw fKHzt3ZMQ78rEmMlx8nCBeTs6tqMfhIU5R+5oXLTekAo8P2LnSI2rbdDKwkqFZaZKded oRoMKJQxVRKSP51f97J6oP6/nY3YNMXyHOSi7BwXuDuM9kxyMi4D7BrJ0cNsweR6Mrif Od1zsp/EZcAwRZhBOBk/f6YRc296PumQUzjWM1AXGfX+6ktUmnK5a1tLhnQOaPBtpdFK xn8w== X-Gm-Message-State: AGRZ1gL/cT5E1nqjffQvLizBKssRpfy1crPP1wskw/B08Wzlyq7qJnBA +M0n42ENG5NyBGbgMyCRNICQAKnK X-Google-Smtp-Source: AJdET5cWGKKRqZoHpXQjYXAsEz8sizDcoRRaerovOPMXKymb8EfgvaK1J6CPYrWAl+aHxLCtEV4tZA== X-Received: by 2002:a1c:1c0c:: with SMTP id c12-v6mr3270775wmc.18.1541540295139; Tue, 06 Nov 2018 13:38:15 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 22:37:54 +0100 Message-Id: <1541540283-45699-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> References: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PULL 08/17] nvdimm: set non-volatile on the memory region X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marc-Andr=C3=A9 Lureau qemu-system-x86_64 -machine pc,nvdimm -m 2G,slots=3D4,maxmem=3D16G -enable-= kvm -monitor stdio -object memory-backend-file,id=3Dmem1,share=3Don,mem-pat= h=3D/tmp/foo,size=3D1G -device nvdimm,id=3Dnvdimm1,memdev=3Dmem1 HMP info mtree command reflects the flag with "nv-" prefix on memory type: (qemu) info mtree 0000000100000000-000000013fffffff (prio 0, nv-i/o): alias nvdimm-memory @/o= bjects/mem1 0000000000000000-000000003fffffff (qemu) info mtree -f 0000000100000000-000000013fffffff (prio 0, nv-ram): /objects/mem1 Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20181003114454.5662-3-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- hw/mem/nvdimm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index 49324f3..bf2adf5 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -116,6 +116,7 @@ static void nvdimm_prepare_memory_region(NVDIMMDevice *= nvdimm, Error **errp) nvdimm->nvdimm_mr =3D g_new(MemoryRegion, 1); memory_region_init_alias(nvdimm->nvdimm_mr, OBJECT(dimm), "nvdimm-memory", mr, 0, pmem_size); + memory_region_set_nonvolatile(nvdimm->nvdimm_mr, true); nvdimm->nvdimm_mr->align =3D align; } =20 --=20 1.8.3.1 From nobody Mon May 6 06:27:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541541408657306.2710978587886; Tue, 6 Nov 2018 13:56:48 -0800 (PST) Received: from localhost ([::1]:43956 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9L5-0006ZM-4l for importer@patchew.org; Tue, 06 Nov 2018 16:56:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9DH-0005fz-3U for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:48:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK93S-000193-55 for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:36 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:41478) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK93R-0000Ij-Ms for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:33 -0500 Received: by mail-wr1-x433.google.com with SMTP id x12-v6so15202021wrw.8 for ; Tue, 06 Nov 2018 13:38:17 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id l186-v6sm3223526wma.13.2018.11.06.13.38.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:38:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6LdTnBLqKTM1XT/evXBfPJzhbQbljIrrP+C/UHHmOk4=; b=bRoZEedpWgKWe5NkyMnrEnSZLiNpdvtBNcbmQjHOdHyvSiQcFlf0R+0izRJI0f6o10 rBxZ1EhpeNQ+CZvixGqtyyjacQpySDYemhE/HXcc482SL7wxfbiTK0jiOj9P/xphOFhM 8vb3U0eo4gwB5RcpN/xmgcPmIyLokv5B+Bb52XFGMT1PrhFP1iDfC02R3MhNISDXFuqP PZY8YincJTv19xdjT5i+d894gnAFVSmbwIQOA4LFcBJE62dptj3Sbztv5Wg4GmDwAsUL OJ0W7oCym5xht+fvvdgYBdHJ61AEQwktXTpc36JJh0Q3jIKfCQ/qa7lmbsIfA7xjKItc /VFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=6LdTnBLqKTM1XT/evXBfPJzhbQbljIrrP+C/UHHmOk4=; b=MJ5xfhPWT26pkX3BoZo6W1WGPrwFPKVPgHTL1TJ6Q1neYl6/A8zi+hGdOupUBG/n7r NBqNJAuthKKSJwl8OFKw5D1N2kAbTRWdOcsC5SpOxHPOX8qPKIc95Mugc+/clmIsXEfv aMQsSa+PW7N9JEulTthQA1OZqQ745BsuyuGHCKqMrhOcIX25IF/ixS52mjqiOpjUyH/B fD+JDW2EiU912WSpFWcsqGoeM5zOYe5osevWXd0Q6WFGgHLBQbEXlZcPWVExm4rqjO8Q bROfhPKy7zzr8OB1YGXK0vVZ2XtqUHf8Gz1HO9S/0iL+OjJoOSHWmHg7S3bKMwsRC7K9 JoQA== X-Gm-Message-State: AGRZ1gJ4o1AuN5nGMPquS89hApCeYBKBGYQvQUg4+vT57i1Cr5ty/PBN IUzXG2wxVFJWYb+KA2cOoQaNAxtW X-Google-Smtp-Source: AJdET5eKfaWXWHp0Rf5DVYPsxBxksDyIlx2qXJHZadGb4iy+g4V3lJWTO7GVQPEt68KXg8l7Z2oVWA== X-Received: by 2002:a5d:6901:: with SMTP id t1-v6mr5629384wru.210.1541540296264; Tue, 06 Nov 2018 13:38:16 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 22:37:55 +0100 Message-Id: <1541540283-45699-10-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> References: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::433 Subject: [Qemu-devel] [PULL 09/17] memory-mapping: skip non-volatile memory regions in GuestPhysBlockList X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marc-Andr=C3=A9 Lureau GuestPhysBlockList is currently used to produce dumps. Given the size and the typical usage of NVDIMM for storage, they are not a good idea to have in the dumps. We may want to have an extra dump option to include them. For now, skip non-volatile regions. The TCG memory clear function is going to use the GuestPhysBlockList as well, and will thus skip NVDIMM for similar reasons. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20181003114454.5662-4-marcandre.lureau@redhat.com> Reviewed-by: Laszlo Ersek Reviewed-by: David Hildenbrand Signed-off-by: Paolo Bonzini --- memory_mapping.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/memory_mapping.c b/memory_mapping.c index 775466f..724dd0b 100644 --- a/memory_mapping.c +++ b/memory_mapping.c @@ -206,7 +206,8 @@ static void guest_phys_blocks_region_add(MemoryListener= *listener, =20 /* we only care about RAM */ if (!memory_region_is_ram(section->mr) || - memory_region_is_ram_device(section->mr)) { + memory_region_is_ram_device(section->mr) || + memory_region_is_nonvolatile(section->mr)) { return; } =20 --=20 1.8.3.1 From nobody Mon May 6 06:27:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541541595890867.2232853522465; Tue, 6 Nov 2018 13:59:55 -0800 (PST) Received: from localhost ([::1]:44015 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9Nq-0002fJ-F1 for importer@patchew.org; Tue, 06 Nov 2018 16:59:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9DF-0003Lq-LF for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:48:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK93R-00016l-Gc for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:36 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:38348) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK93R-0000MR-4D for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:33 -0500 Received: by mail-wm1-x335.google.com with SMTP id f2-v6so150225wme.3 for ; Tue, 06 Nov 2018 13:38:18 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id l186-v6sm3223526wma.13.2018.11.06.13.38.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:38:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ACjNwV1+MwKQA/PPpL4CyEmvEY7lwtsyBF4hWNYo51c=; b=NKjgCeFi5jCjTEOkZ1BoBgBjxIHdPOpXnt+RIiXnmMDV4TLbXwPg4UYAtWQ22xCsss 1wT65Ozgi1XW91hWf+xRq+N2BA3zXYLFNwVLMwyYdQsxUIdM71QFCSC/oofK8qG1w12y XtWQlR+6fmMpwxH7eEaxTmBgeLZN9OtPa1GSkluSzlTZJGiHii9bTwQWKGl6VH0QVE2c /6J2jGOW5uUFG2TyXmRWZ2BgW46iHipY3C641LQu2nSFmv9aQL9FvBNFa7KTWmiO/OQ+ zjDO5VP+wVFssXgXmdc0BriILdgeyJoWTqdVlTJtlZ4zkDciEKSOsHIdWpsL3W1Ap1Ze B3IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ACjNwV1+MwKQA/PPpL4CyEmvEY7lwtsyBF4hWNYo51c=; b=L+cm3qUQ7WZkm6w6P3OsFlE0LFAqRrcgU4bx2dym+DlxXnmL9Q0GEW4iDeCRT++GFY BJoe2fOqFIp1anIprcPTIuFc0SgRJgc0V0VdQYmWFlK3wrv4bia89VSj9clnFeCq7qQf /n77fIPd8bTp72dBX/CMxZyaY/FoRb5Kk+JnRVCdHQjHjroqeN62up2IxzsttEc5o5kj u+uD1cebcc280ZkKNIy+kh1qGxA/yOHDoB+rdIK+RfOyQsMizp6bn1AppftYZb1WCgFg jwCarIKm/RVq6dqvPukUXF7VK0kF3qI3ZGURwlxxWHDU7tjQLcBVPQd73E+v8p2AyH+l 7Zdg== X-Gm-Message-State: AGRZ1gLin33eMJczwnRJintyCKD/k2CGCBmICvzOcLOM3nOA4jn79QA6 7FRMEkUHIqn//+0Tb20+N8KPM2W4 X-Google-Smtp-Source: AJdET5cm3l3UCehd1lvNeLsZsiXJTH+QdI8tWzrjdDg4qB9QhKwyuuxkXWeLdpC4YInySbx9HXnoZQ== X-Received: by 2002:a1c:c284:: with SMTP id s126-v6mr3248429wmf.21.1541540297392; Tue, 06 Nov 2018 13:38:17 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 22:37:56 +0100 Message-Id: <1541540283-45699-11-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> References: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::335 Subject: [Qemu-devel] [PULL 10/17] scripts/dump-guest-memory: Synchronize with guest_phys_blocks_region_add X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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: fail (Header signature does not verify) Recent patches have removed ram_device and nonvolatile RAM from dump-guest-memory's output. Do the same for dumps that are extracted from a QEMU core file. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini --- scripts/dump-guest-memory.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py index 5a857ce..198cd0f 100644 --- a/scripts/dump-guest-memory.py +++ b/scripts/dump-guest-memory.py @@ -417,7 +417,9 @@ def get_guest_phys_blocks(): memory_region =3D flat_range["mr"].dereference() =20 # we only care about RAM - if not memory_region["ram"]: + if (not memory_region["ram"] or + memory_region["ram_device"] or + memory_region["nonvolatile"]): continue =20 section_size =3D int128_get64(flat_range["addr"]["size"]) --=20 1.8.3.1 From nobody Mon May 6 06:27:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541541429357945.4798958261755; Tue, 6 Nov 2018 13:57:09 -0800 (PST) Received: from localhost ([::1]:43957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9LQ-0006ph-5r for importer@patchew.org; Tue, 06 Nov 2018 16:57:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9Cx-0006PE-Fg for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:48:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK93U-0001HY-CE for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:40 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:46284) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK93T-0000P6-Ms for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:36 -0500 Received: by mail-wr1-x441.google.com with SMTP id 74-v6so15189970wrb.13 for ; Tue, 06 Nov 2018 13:38:19 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id l186-v6sm3223526wma.13.2018.11.06.13.38.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:38:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=OaEiRFoorDQ9iC1MAXlZbRKhGaEH4QOy9SLDxZ4Pcq8=; b=vFMic9Xh0k7tqiuMR9G1VnPNYQ1gcRwOYolFZsPX/l6p2V+qDVxYHbDd9VhOFepVrr liRjMM08GzWIgct/qH9MLPUkIkB3fYnfwbu/UqIT/hQ/BTnpifto/ErLqy+1U2m141EF DulD0hN1aczumMd3mjU8/Z4g6ZgRRq25K904JZ6IRsCCVXZc0jbfEn7E2n1WvvEEWUgz FgFuS1XY5WXR4XOPyFEMT6BKWxZQzA0f4IjLIpx/01nD24pkCVbpabQoyET0QMRUuH/f RxKgXZEJ6KQWFh7lYEjkwhe0NNsN2LNPE4KpA92hRmBeuzvPfaF44tYe3dVOeppBT8Ml Dqsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=OaEiRFoorDQ9iC1MAXlZbRKhGaEH4QOy9SLDxZ4Pcq8=; b=LCB7jsDtqCiLBCvLO+APIl6oCrLAoBnZ7vTt0PD7WL6wnY4WeheQ3EfFu5Q602NoAw ToEKYLsbw7lfb5bYptvgQfE3OazR3qwLockN7sZfb5S+OIoXiC2DleK6b9dFhYKxO+s3 5Hi5rgw0zZSLihy6oy3Zshr0JOCCpy6W78HsIVFnhATyeInwMSBDeNyRW1c1QuNFV8s8 t6t+lx1kBPCbXROadbi+7mtC8XeS4gIjygzscL62GfGe3b/uRKQWKtc1zzyjxYr2FaLY weWTShNqVSM3nhdvsyMBPUufD8MrzB1kw1A1EaxMyvGcCgpzAbWfr2Bqkasq6SX5sYXC WBuw== X-Gm-Message-State: AGRZ1gKNiiFdvFYY4voD6hATg21t6/tDl8i6BIYiuH4zutrSBYNoexGL WJRFFr6uAGSfcJZDXf/1UJOrWYbZ X-Google-Smtp-Source: AJdET5dmfESV66HB7GlcJfBlhORP+kH3vva3sit8aO2Su/GW6R4BDYYKsqHBtLreKFrhp9/OGWOp0w== X-Received: by 2002:a05:6000:110b:: with SMTP id z11mr24196878wrw.136.1541540298598; Tue, 06 Nov 2018 13:38:18 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 22:37:57 +0100 Message-Id: <1541540283-45699-12-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> References: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PULL 11/17] lsi53c895a: check message length value is valid X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Prasad J Pandit While writing a message in 'lsi_do_msgin', message length value in 'msg_len' could be invalid due to an invalid migration stream. Add an assertion to avoid an out of bounds access, and reject the incoming migration data if it contains an invalid message length. Discovered by Deja vu Security. Reported by Oracle. Signed-off-by: Prasad J Pandit Message-Id: <20181026194314.18663-1-ppandit@redhat.com> Signed-off-by: Paolo Bonzini --- hw/scsi/lsi53c895a.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index d1e6534..3f207f6 100644 --- a/hw/scsi/lsi53c895a.c +++ b/hw/scsi/lsi53c895a.c @@ -861,10 +861,11 @@ static void lsi_do_status(LSIState *s) =20 static void lsi_do_msgin(LSIState *s) { - int len; + uint8_t len; trace_lsi_do_msgin(s->dbc, s->msg_len); s->sfbr =3D s->msg[0]; len =3D s->msg_len; + assert(len > 0 && len <=3D LSI_MAX_MSGIN_LEN); if (len > s->dbc) len =3D s->dbc; pci_dma_write(PCI_DEVICE(s), s->dnad, s->msg, len); @@ -1705,8 +1706,10 @@ static uint8_t lsi_reg_readb(LSIState *s, int offset) break; case 0x58: /* SBDL */ /* Some drivers peek at the data bus during the MSG IN phase. */ - if ((s->sstat1 & PHASE_MASK) =3D=3D PHASE_MI) + if ((s->sstat1 & PHASE_MASK) =3D=3D PHASE_MI) { + assert(s->msg_len > 0); return s->msg[0]; + } ret =3D 0; break; case 0x59: /* SBDL high */ @@ -2103,11 +2106,23 @@ static int lsi_pre_save(void *opaque) return 0; } =20 +static int lsi_post_load(void *opaque, int version_id) +{ + LSIState *s =3D opaque; + + if (s->msg_len < 0 || s->msg_len > LSI_MAX_MSGIN_LEN) { + return -EINVAL; + } + + return 0; +} + static const VMStateDescription vmstate_lsi_scsi =3D { .name =3D "lsiscsi", .version_id =3D 0, .minimum_version_id =3D 0, .pre_save =3D lsi_pre_save, + .post_load =3D lsi_post_load, .fields =3D (VMStateField[]) { VMSTATE_PCI_DEVICE(parent_obj, LSIState), =20 --=20 1.8.3.1 From nobody Mon May 6 06:27:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541541044122222.32321439622103; Tue, 6 Nov 2018 13:50:44 -0800 (PST) Received: from localhost ([::1]:43908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9FC-0007ug-Te for importer@patchew.org; Tue, 06 Nov 2018 16:50:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9Cr-0002l5-SE for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:48:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK93V-0001Md-Gs for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:40 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:55896) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK93U-0000Ta-S2 for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:37 -0500 Received: by mail-wm1-x32e.google.com with SMTP id s10-v6so12270162wmc.5 for ; Tue, 06 Nov 2018 13:38:21 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id l186-v6sm3223526wma.13.2018.11.06.13.38.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:38:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=7jtD+eeTjd74bM8YAjvzXqkdpx9pwaHl6iZohtFPpLg=; b=OybQhaIlBRrFvFq+PP+sboZKUz0XRzDUFv1QEO/7YaGTPRAfsGpGe+6Q/NLZm5rBz7 uLFsUnSNwbxlDqMvIgOzdtJJGPfZStxvyeBxAtNuRWFPbGy81fqjYhsGsLSWD/HICtuS yJz7w/KouGXrneFQb6FQwZOqF9Xd8kGGV7/GXn4JkF8YOVZ3wpAUwV+/swiECf9fFL7/ pR5i8Ep/W8y67jxC8soAq+dGuX+WOR5oKzYasS3L3DBr9mEfnnZO5WQ6Hx7qe1AWFNza X5bLlHqDcKOkzTwb/tgqfG3GCKn/DbKUPwOhCvEs9WFM9ztHE//wbcbGrVEvFtmfvfla 8VaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=7jtD+eeTjd74bM8YAjvzXqkdpx9pwaHl6iZohtFPpLg=; b=Gj1J3em/RseunS3s0ZRl2s6K4mBeahJUnmnfmH98BYBPJam8knhJrign1TRFiOz6Ok szfSVItDZjsog5ja6wEdUNwNf9saPY4XikZUYDFDF/mvRFooSvbgyK9jhMcBqfj1s8vb IIhSLmSEds1LZJitNY5RSyqTxRfybZjr3LhTcgaQS9G2JhUTOQgERZkhF2+CFNDcnG3E OGjU1KBK5QPM+U0NieGLk/B3wmNv9bQKgq6wdX340bstpaxWwN3yD9IJQz/2NGGp8Q0s DypNEQZyf0QngkI3V+4BM4Lj0ZHOXTgN8fZtgAH8EYBt/cLv0W0FpLJceR24pZC+EszQ vixQ== X-Gm-Message-State: AGRZ1gIAn3J9l3FhL6PHWeS5gSWITNgQad1JWaVHgVVyGP7/vVxOugh3 5zZ7gE2OJJ8bHeS3CToW2sk55bLZ X-Google-Smtp-Source: AJdET5dAK79bD3+9QlDoPThcKs77osUz4XMJ4w+3oKebsZq0YrPEjy0zYmqdynhBliYCvC8Xmk9UIg== X-Received: by 2002:a1c:3e84:: with SMTP id l126-v6mr3296646wma.91.1541540300328; Tue, 06 Nov 2018 13:38:20 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 22:37:58 +0100 Message-Id: <1541540283-45699-13-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> References: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32e Subject: [Qemu-devel] [PULL 12/17] scsi-generic: keep VPD page list sorted X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Block limits emulation is just placing 0xb0 as the final byte of the VPD pages list. However, VPD page numbers must be sorted, so change that to an in-place insert. Since I couldn't find any disk that triggered the loop more than once, this was tested by adding manually 0xb1 at the end of the list and checking that 0xb0 was added before. Reported-by: Max Reitz Reviewed-by: Max Reitz Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-generic.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index d60c4d0..aebb7cd 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -144,7 +144,7 @@ static int execute_command(BlockBackend *blk, =20 static void scsi_handle_inquiry_reply(SCSIGenericReq *r, SCSIDevice *s) { - uint8_t page, page_len; + uint8_t page, page_idx; =20 /* * EVPD set to zero returns the standard INQUIRY data. @@ -190,10 +190,21 @@ static void scsi_handle_inquiry_reply(SCSIGenericReq = *r, SCSIDevice *s) * * This way, the guest kernel will be aware of the support * and will use it to proper setup the SCSI device. + * + * VPD page numbers must be sorted, so insert 0xb0 at the + * right place with an in-place insert. After the initializat= ion + * part of the for loop is executed, the device response is + * at r[0] to r[page_idx - 1]. */ - page_len =3D r->buf[3]; - r->buf[page_len + 4] =3D 0xb0; - r->buf[3] =3D ++page_len; + for (page_idx =3D lduw_be_p(r->buf + 2) + 4; + page_idx > 4 && r->buf[page_idx - 1] >=3D 0xb0; + page_idx--) { + if (page_idx < r->buflen) { + r->buf[page_idx] =3D r->buf[page_idx - 1]; + } + } + r->buf[page_idx] =3D 0xb0; + stw_be_p(r->buf + 2, lduw_be_p(r->buf + 2) + 1); } } } --=20 1.8.3.1 From nobody Mon May 6 06:27:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541541234969244.55342719710188; Tue, 6 Nov 2018 13:53:54 -0800 (PST) Received: from localhost ([::1]:43932 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9I3-0003SR-BH for importer@patchew.org; Tue, 06 Nov 2018 16:53:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9Cq-0002lF-3M for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:48:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK93X-0001Uu-UC for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:43 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:53596) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK93W-0000WI-Hx for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:39 -0500 Received: by mail-wm1-x32e.google.com with SMTP id f10-v6so85694wme.3 for ; Tue, 06 Nov 2018 13:38:22 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id l186-v6sm3223526wma.13.2018.11.06.13.38.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:38:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=zCPr4JzfsgrE6KwOgTmKxZIbDvG8Wrm2x67VsyGQQY4=; b=mQAdMvaFR34v2ySiCwYHl4+RF3hcd5h18Jm9Q49H5l5gkro4RC1Xdj26EEVKUhfYxW nyGPP74Ni9MsLcdadY1zTz47w6JGNX5ZL4wiavjkI05PjP/iwFi0oyDLSlxgw7gJFutX 43RrzOyYy2UwywC4lJCFXWgKrBXpszmrjUW3Ywpo9xpwM6/31IteCjUPtw4jbl5NNPt+ psZYWvto8uRdZ2iK4Ut32QofelBs/DO1xSJx+pc+kG3j2N7//IZAk444neqhiRIZootI 2UTph0fqh6+0hvWuzPo/AZpZ/wJdyeHR6k5rzfCmCJdco47EfG1IIdoD5oiR9zLSE5X5 YRvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=zCPr4JzfsgrE6KwOgTmKxZIbDvG8Wrm2x67VsyGQQY4=; b=d1AyBnYL/QEdlrCOR2Rs58L5BrYgINu8pgZqsyh6MnNlxCak21TvDbG6UEgqhKNwPP TJx9n27a+i4XLjY0Zc3nDb+khZX/lIX/pbcUxfmvRxROFdWxeJYSYC2qT7qL+SMeS3lD 7pEIp1gKhK42bMldT44ghgn2y+Kjy14wT7KmIYuDr5cprr/Dr9oL1wY3Ocpzp75l1PCv w5Lr7k4+hkSnBiGLRY3TKTeKuQclybFkhXdsk9v8TwAPFTuyvsXJYx1lxmiNKt7WuuBG wn2L5m0xaIG+a5y1fZOIwppeTrGAkOdqTdLqMx9Iq0sVfUh3ravIyEK+8mNWwSJofSck VK3A== X-Gm-Message-State: AGRZ1gI4jLPZBs6L/nOG+kUBnR1YaVb0NL4bd6QsqLB1ENrrdGcSEZx0 LrfebaEWInhaPMcW2kr8W37pvM4R X-Google-Smtp-Source: AJdET5eV6ePy1LLsw6JZkE/VyXHCoZTfJCT75/WJ3cBLPdQydX04fMnbB0ou0TLRiTo6yfIkVN5q9A== X-Received: by 2002:a1c:4d2:: with SMTP id 201-v6mr3238417wme.133.1541540301372; Tue, 06 Nov 2018 13:38:21 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 22:37:59 +0100 Message-Id: <1541540283-45699-14-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> References: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32e Subject: [Qemu-devel] [PULL 13/17] scsi-generic: avoid out-of-bounds access to VPD page list X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" A device can report an excessive number of VPD pages when asked for a list; this can cause an out-of-bounds access to buf in scsi_generic_set_vpd_bl_emulation. It should not happen, but it is technically not incorrect so handle it: do not check any byte past the allocation length that was sent to the INQUIRY command. Reported-by: Max Reitz Reviewed-by: Max Reitz Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index aebb7cd..c5497bb 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -538,7 +538,7 @@ static void scsi_generic_set_vpd_bl_emulation(SCSIDevic= e *s) } =20 page_len =3D buf[3]; - for (i =3D 4; i < page_len + 4; i++) { + for (i =3D 4; i < MIN(sizeof(buf), page_len + 4); i++) { if (buf[i] =3D=3D 0xb0) { s->needs_vpd_bl_emulation =3D false; return; --=20 1.8.3.1 From nobody Mon May 6 06:27:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541541040305938.3783869705549; Tue, 6 Nov 2018 13:50:40 -0800 (PST) Received: from localhost ([::1]:43905 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9F9-0007ol-5D for importer@patchew.org; Tue, 06 Nov 2018 16:50:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9Ck-0003Nh-MJ for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:48:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK93W-0001Py-GF for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:45 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:32881) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK93V-0000Zn-Hv for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:38 -0500 Received: by mail-wr1-x444.google.com with SMTP id u9-v6so4866022wrr.0 for ; Tue, 06 Nov 2018 13:38:23 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id l186-v6sm3223526wma.13.2018.11.06.13.38.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:38:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=NkRKCpV8Fxy9Qn+W3z8+uh3QskpziEyqIgH9Rb61n4s=; b=ADbGevKXsEeRdGINyy88VbFKQDtYZOjwydJcuGgMiHSRNGEyzEBQ0K7h1nYIFuJmk+ O5Ih8thwAFW+pRDTfveDFP3Kz4yzLS4SZqj3rhy4cmzmrMXAhOCNOBa7k+IEZWVeM07x MUM261EDHKMqTdskrrLAGQLmEltpOLytKkXDztzp3LOTxYH1uIzvtJYc8gQHuxrhgH+5 Fmg/SzMkFPtl68Y0XdMOfFTA8/5ApEiHjy4ljofv7/ZV6KvaFVQmsuatoq7qh5cFNF9t 8fLUqRwZlPmmFo0DrbeIvoQQB/dvDGQIHZ2AJM0c7yCrvXifAPjg0aXMD1GqmUw9v/A8 Bd6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=NkRKCpV8Fxy9Qn+W3z8+uh3QskpziEyqIgH9Rb61n4s=; b=B+IOFm1SPxxV41Mwo8cOOxQEtTibJyiI4GZwfntIYweoYCf7lOpw2J3vDv0TbVsFhp kM+tJFaQE30FyZw1hlGtkym0Zy0wjrC5yQTxuzwYiimabkDGG9iJtpFQEDzX9rzKfZyY ViP3OI8lzNvV7g8quAzP75k2eNLDt68FSYzk8RE+BbG8xEjy3DeKtz6Ca0Sksuiz9HT6 2DpqMobpQ0Z4snMc9trNSr7Lf6/Ar2M1vdnY1f0n61Und+aXXPQQcJKbwIoWQnbj9hon 0gNTh4NFTKo6ZmseGitB8Q1CFq2QbAgblYIw9Et05440sfQk9QphchOS7mDpx9hD4DEf qIhQ== X-Gm-Message-State: AGRZ1gLcgHR7zk1QmlfsFH62Dy2w22AibdiMP/3NxFElZSrf3abtjG0m 0IIeMp3Wzz+qT0EIHbPg7dTWqCoK X-Google-Smtp-Source: AJdET5eVLqvjy8kd2Cv4E3K/fHL/CuKSoX5QQWGzH1moQg0FG3pket57VLzUX/UEG7Gkd8BUVTbTuQ== X-Received: by 2002:adf:9589:: with SMTP id p9-v6mr25518097wrp.270.1541540302487; Tue, 06 Nov 2018 13:38:22 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 22:38:00 +0100 Message-Id: <1541540283-45699-15-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> References: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PULL 14/17] scsi-generic: avoid invalid access to struct when emulating block limits X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Emulation of the block limits VPD page called back into scsi-disk.c, which however expected the request to be for a SCSIDiskState and accessed a scsi-generic device outside the bounds of its struct (namely to retrieve s->max_unmap_size and s->max_io_size). To avoid this, move the emulation code to a separate function that takes a new SCSIBlockLimits struct and marshals it into the VPD response format. Reported-by: Max Reitz Reviewed-by: Max Reitz Signed-off-by: Paolo Bonzini --- hw/scsi/Makefile.objs | 2 +- hw/scsi/emulation.c | 42 +++++++++++++++++++++ hw/scsi/scsi-disk.c | 92 ++++++++++-------------------------------= ---- hw/scsi/scsi-generic.c | 35 ++++++++++++----- include/hw/scsi/emulation.h | 16 ++++++++ include/hw/scsi/scsi.h | 1 - 6 files changed, 104 insertions(+), 84 deletions(-) create mode 100644 hw/scsi/emulation.c create mode 100644 include/hw/scsi/emulation.h diff --git a/hw/scsi/Makefile.objs b/hw/scsi/Makefile.objs index 718b4c2..45167ba 100644 --- a/hw/scsi/Makefile.objs +++ b/hw/scsi/Makefile.objs @@ -1,4 +1,4 @@ -common-obj-y +=3D scsi-disk.o +common-obj-y +=3D scsi-disk.o emulation.o common-obj-y +=3D scsi-generic.o scsi-bus.o common-obj-$(CONFIG_LSI_SCSI_PCI) +=3D lsi53c895a.o common-obj-$(CONFIG_MPTSAS_SCSI_PCI) +=3D mptsas.o mptconfig.o mptendian.o diff --git a/hw/scsi/emulation.c b/hw/scsi/emulation.c new file mode 100644 index 0000000..06d62f3 --- /dev/null +++ b/hw/scsi/emulation.c @@ -0,0 +1,42 @@ +#include "qemu/osdep.h" +#include "qemu/units.h" +#include "qemu/bswap.h" +#include "hw/scsi/emulation.h" + +int scsi_emulate_block_limits(uint8_t *outbuf, const SCSIBlockLimits *bl) +{ + /* required VPD size with unmap support */ + memset(outbuf, 0, 0x3c); + + outbuf[0] =3D bl->wsnz; /* wsnz */ + + if (bl->max_io_sectors) { + /* optimal transfer length granularity. This field and the optimal + * transfer length can't be greater than maximum transfer length. + */ + stw_be_p(outbuf + 2, MIN(bl->min_io_size, bl->max_io_sectors)); + + /* maximum transfer length */ + stl_be_p(outbuf + 4, bl->max_io_sectors); + + /* optimal transfer length */ + stl_be_p(outbuf + 8, MIN(bl->opt_io_size, bl->max_io_sectors)); + } else { + stw_be_p(outbuf + 2, bl->min_io_size); + stl_be_p(outbuf + 8, bl->opt_io_size); + } + + /* max unmap LBA count */ + stl_be_p(outbuf + 16, bl->max_unmap_sectors); + + /* max unmap descriptors */ + stl_be_p(outbuf + 20, bl->max_unmap_descr); + + /* optimal unmap granularity; alignment is zero */ + stl_be_p(outbuf + 24, bl->unmap_sectors); + + /* max write same size, make it the same as maximum transfer length */ + stl_be_p(outbuf + 36, bl->max_io_sectors); + + return 0x3c; +} diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index e2c5408..6eb258d 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -33,6 +33,7 @@ do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while = (0) #include "qapi/error.h" #include "qemu/error-report.h" #include "hw/scsi/scsi.h" +#include "hw/scsi/emulation.h" #include "scsi/constants.h" #include "sysemu/sysemu.h" #include "sysemu/block-backend.h" @@ -589,7 +590,7 @@ static uint8_t *scsi_get_buf(SCSIRequest *req) return (uint8_t *)r->iov.iov_base; } =20 -int scsi_disk_emulate_vpd_page(SCSIRequest *req, uint8_t *outbuf) +static int scsi_disk_emulate_vpd_page(SCSIRequest *req, uint8_t *outbuf) { SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, req->dev); uint8_t page_code =3D req->cmd.buf[2]; @@ -691,89 +692,36 @@ int scsi_disk_emulate_vpd_page(SCSIRequest *req, uint= 8_t *outbuf) } case 0xb0: /* block limits */ { - unsigned int unmap_sectors =3D - s->qdev.conf.discard_granularity / s->qdev.blocksize; - unsigned int min_io_size =3D - s->qdev.conf.min_io_size / s->qdev.blocksize; - unsigned int opt_io_size =3D - s->qdev.conf.opt_io_size / s->qdev.blocksize; - unsigned int max_unmap_sectors =3D - s->max_unmap_size / s->qdev.blocksize; - unsigned int max_io_sectors =3D - s->max_io_size / s->qdev.blocksize; + SCSIBlockLimits bl =3D {}; =20 if (s->qdev.type =3D=3D TYPE_ROM) { DPRINTF("Inquiry (EVPD[%02X] not supported for CDROM\n", page_code); return -1; } + bl.wsnz =3D 1; + bl.unmap_sectors =3D + s->qdev.conf.discard_granularity / s->qdev.blocksize; + bl.min_io_size =3D + s->qdev.conf.min_io_size / s->qdev.blocksize; + bl.opt_io_size =3D + s->qdev.conf.opt_io_size / s->qdev.blocksize; + bl.max_unmap_sectors =3D + s->max_unmap_size / s->qdev.blocksize; + bl.max_io_sectors =3D + s->max_io_size / s->qdev.blocksize; + /* 255 descriptors fit in 4 KiB with an 8-byte header */ + bl.max_unmap_descr =3D 255; + if (s->qdev.type =3D=3D TYPE_DISK) { int max_transfer_blk =3D blk_get_max_transfer(s->qdev.conf.blk= ); int max_io_sectors_blk =3D max_transfer_blk / s->qdev.blocksize; =20 - max_io_sectors =3D - MIN_NON_ZERO(max_io_sectors_blk, max_io_sectors); - - /* min_io_size and opt_io_size can't be greater than - * max_io_sectors */ - if (min_io_size) { - min_io_size =3D MIN(min_io_size, max_io_sectors); - } - if (opt_io_size) { - opt_io_size =3D MIN(opt_io_size, max_io_sectors); - } + bl.max_io_sectors =3D + MIN_NON_ZERO(max_io_sectors_blk, bl.max_io_sectors); } - /* required VPD size with unmap support */ - buflen =3D 0x40; - memset(outbuf + 4, 0, buflen - 4); - - outbuf[4] =3D 0x1; /* wsnz */ - - /* optimal transfer length granularity */ - outbuf[6] =3D (min_io_size >> 8) & 0xff; - outbuf[7] =3D min_io_size & 0xff; - - /* maximum transfer length */ - outbuf[8] =3D (max_io_sectors >> 24) & 0xff; - outbuf[9] =3D (max_io_sectors >> 16) & 0xff; - outbuf[10] =3D (max_io_sectors >> 8) & 0xff; - outbuf[11] =3D max_io_sectors & 0xff; - - /* optimal transfer length */ - outbuf[12] =3D (opt_io_size >> 24) & 0xff; - outbuf[13] =3D (opt_io_size >> 16) & 0xff; - outbuf[14] =3D (opt_io_size >> 8) & 0xff; - outbuf[15] =3D opt_io_size & 0xff; - - /* max unmap LBA count, default is 1GB */ - outbuf[20] =3D (max_unmap_sectors >> 24) & 0xff; - outbuf[21] =3D (max_unmap_sectors >> 16) & 0xff; - outbuf[22] =3D (max_unmap_sectors >> 8) & 0xff; - outbuf[23] =3D max_unmap_sectors & 0xff; - - /* max unmap descriptors, 255 fit in 4 kb with an 8-byte header */ - outbuf[24] =3D 0; - outbuf[25] =3D 0; - outbuf[26] =3D 0; - outbuf[27] =3D 255; - - /* optimal unmap granularity */ - outbuf[28] =3D (unmap_sectors >> 24) & 0xff; - outbuf[29] =3D (unmap_sectors >> 16) & 0xff; - outbuf[30] =3D (unmap_sectors >> 8) & 0xff; - outbuf[31] =3D unmap_sectors & 0xff; - - /* max write same size */ - outbuf[36] =3D 0; - outbuf[37] =3D 0; - outbuf[38] =3D 0; - outbuf[39] =3D 0; - - outbuf[40] =3D (max_io_sectors >> 24) & 0xff; - outbuf[41] =3D (max_io_sectors >> 16) & 0xff; - outbuf[42] =3D (max_io_sectors >> 8) & 0xff; - outbuf[43] =3D max_io_sectors & 0xff; + buflen +=3D scsi_emulate_block_limits(outbuf + buflen, &bl); break; } case 0xb1: /* block device characteristics */ diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index c5497bb..b50ce64 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -16,6 +16,7 @@ #include "qemu-common.h" #include "qemu/error-report.h" #include "hw/scsi/scsi.h" +#include "hw/scsi/emulation.h" #include "sysemu/block-backend.h" =20 #ifdef __linux__ @@ -181,7 +182,7 @@ static void scsi_handle_inquiry_reply(SCSIGenericReq *r= , SCSIDevice *s) /* Also take care of the opt xfer len. */ stl_be_p(&r->buf[12], MIN_NON_ZERO(max_transfer, ldl_be_p(&r->buf[12]))); - } else if (page =3D=3D 0x00 && s->needs_vpd_bl_emulation) { + } else if (s->needs_vpd_bl_emulation && page =3D=3D 0x00) { /* * Now we're capable of supplying the VPD Block Limits * response if the hardware can't. Add it in the INQUIRY @@ -209,9 +210,24 @@ static void scsi_handle_inquiry_reply(SCSIGenericReq *= r, SCSIDevice *s) } } =20 -static int scsi_emulate_block_limits(SCSIGenericReq *r) +static int scsi_generic_emulate_block_limits(SCSIGenericReq *r, SCSIDevice= *s) { - r->buflen =3D scsi_disk_emulate_vpd_page(&r->req, r->buf); + int len; + uint8_t buf[64]; + + SCSIBlockLimits bl =3D { + .max_io_sectors =3D blk_get_max_transfer(s->conf.blk) / s->blocksi= ze + }; + + memset(r->buf, 0, r->buflen); + stb_p(buf, s->type); + stb_p(buf + 1, 0xb0); + len =3D scsi_emulate_block_limits(buf + 4, &bl); + assert(len <=3D sizeof(buf) - 4); + stw_be_p(buf + 2, len); + + memcpy(r->buf, buf, MIN(r->buflen, len + 4)); + r->io_header.sb_len_wr =3D 0; =20 /* @@ -253,13 +269,12 @@ static void scsi_read_complete(void * opaque, int ret) * resulted in sense error but would need emulation. * In this case, emulate a valid VPD response. */ - if (s->needs_vpd_bl_emulation) { - int is_vpd_bl =3D r->req.cmd.buf[0] =3D=3D INQUIRY && - r->req.cmd.buf[1] & 0x01 && - r->req.cmd.buf[2] =3D=3D 0xb0; - - if (is_vpd_bl && sg_io_sense_from_errno(-ret, &r->io_header, &sens= e)) { - len =3D scsi_emulate_block_limits(r); + if (s->needs_vpd_bl_emulation && + r->req.cmd.buf[0] =3D=3D INQUIRY && + (r->req.cmd.buf[1] & 0x01) && + r->req.cmd.buf[2] =3D=3D 0xb0) { + if (sg_io_sense_from_errno(-ret, &r->io_header, &sense)) { + len =3D scsi_generic_emulate_block_limits(r, s); /* * No need to let scsi_read_complete go on and handle an * INQUIRY VPD BL request we created manually. diff --git a/include/hw/scsi/emulation.h b/include/hw/scsi/emulation.h new file mode 100644 index 0000000..09fba1f --- /dev/null +++ b/include/hw/scsi/emulation.h @@ -0,0 +1,16 @@ +#ifndef HW_SCSI_EMULATION_H +#define HW_SCSI_EMULATION_H 1 + +typedef struct SCSIBlockLimits { + bool wsnz; + uint16_t min_io_size; + uint32_t max_unmap_descr; + uint32_t opt_io_size; + uint32_t max_unmap_sectors; + uint32_t unmap_sectors; + uint32_t max_io_sectors; +} SCSIBlockLimits; + +int scsi_emulate_block_limits(uint8_t *outbuf, const SCSIBlockLimits *bl); + +#endif diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index ee3a411..acef25f 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -189,7 +189,6 @@ void scsi_device_report_change(SCSIDevice *dev, SCSISen= se sense); void scsi_device_unit_attention_reported(SCSIDevice *dev); void scsi_generic_read_device_inquiry(SCSIDevice *dev); int scsi_device_get_sense(SCSIDevice *dev, uint8_t *buf, int len, bool fix= ed); -int scsi_disk_emulate_vpd_page(SCSIRequest *req, uint8_t *outbuf); int scsi_SG_IO_FROM_DEV(BlockBackend *blk, uint8_t *cmd, uint8_t cmd_size, uint8_t *buf, uint8_t buf_size); SCSIDevice *scsi_device_find(SCSIBus *bus, int channel, int target, int lu= n); --=20 1.8.3.1 From nobody Mon May 6 06:27:37 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15415415976541014.4640775751349; Tue, 6 Nov 2018 13:59:57 -0800 (PST) Received: from localhost ([::1]:44014 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9No-0002dn-QY for importer@patchew.org; Tue, 06 Nov 2018 16:59:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9D5-0005fz-KW for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:48:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK93T-0001Dy-LF for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:38 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:37782) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK93S-0000bF-W7 for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:35 -0500 Received: by mail-wm1-x333.google.com with SMTP id p2-v6so13717363wmc.2 for ; Tue, 06 Nov 2018 13:38:24 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id l186-v6sm3223526wma.13.2018.11.06.13.38.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:38:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=WgZvR0RbKUtZsROKV+ztLGGbfoQL0YxAqUmRVNKBrN8=; b=hkBW4Dg3Pr+8BZrp4E4mMwV6VIBuC0ZdWdmsOWZ7LLzACO2pVtnJwWecJ1m/qgAfe7 PAbijLQq7g3x2NjurY5wEj6FVdfjjiRHOYTjZi3/8vVVKp0A1T8aW8X3bcQAV/U9oYA6 fLPYS3zh4erw36n7VS8JGYhMfFB30niQXQP7a4RwJs/OHdLsxmH7VyBbfLFwNFTk36jj 2Rk7Mfe9VSiLJySb5rF9u03OCMKjE8EsmB+MUFCMyccVye3U0cKOuhPyo9SQOJFusu+q XR0hhKpT9EKgGR4O1Z1xFNc7qhR3WuQNvZ9N2UkUEN4bE8p7q2CsOtGN45kUSmJxP0Tq VCKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=WgZvR0RbKUtZsROKV+ztLGGbfoQL0YxAqUmRVNKBrN8=; b=miYSNfW8Fyj8H4zg+mi7pIEiMJs0QUPFOjxgFaAovdmmYtbopv71EBQFXs4TlsfP7Y 4Ejm11PRTG5CJQs4zxBbZjCeKfgHdPnRxyyYeGsgw9K17ZXhQuRpkR0waDZb4AmYUq1q 8YXQnuSbc+KN4OX40s/INCgflxeNtsbuz3mhfIWqhlFMzRW1IJRtbsLmTL+B4cB8Y0+V KryvuD/VF050Wr9WjWTwqeI66sO/FJk5Ihr/+jNzFPyp6TMSQB/qSmYdXvm7NJh1dC5D qsJbTMlJebtJGPkGcGgJsqb1KOaUT4Ami47Nf52NkoCf3KzuvTKMTtChUQ5D8CRBrFm0 AsNw== X-Gm-Message-State: AGRZ1gLOv34M+4OAtQHR46QPJg0Lwuwj6oR0r+5P1KYLbF/mNwIPlL7P KDLhWlTrBIwnq2i5o5IJtgMV3Ezp X-Google-Smtp-Source: AJdET5eTbPwdCzSgQSeGozvWgUHWijVyVlU9hF4++wlhn46+W8bdN9DscWi/BME2YW7U+Roxk4/xOQ== X-Received: by 2002:a1c:a910:: with SMTP id s16-v6mr3332729wme.86.1541540303219; Tue, 06 Nov 2018 13:38:23 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 22:38:01 +0100 Message-Id: <1541540283-45699-16-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> References: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::333 Subject: [Qemu-devel] [PULL 15/17] scsi-generic: do not do VPD emulation for sense other than ILLEGAL_REQUEST X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Pass other sense, such as UNIT_ATTENTION or BUSY, directly to the guest. Reported-by: Max Reitz Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-generic.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index b50ce64..7237b41 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -246,7 +246,6 @@ static void scsi_read_complete(void * opaque, int ret) { SCSIGenericReq *r =3D (SCSIGenericReq *)opaque; SCSIDevice *s =3D r->req.dev; - SCSISense sense; int len; =20 assert(r->req.aiocb !=3D NULL); @@ -269,11 +268,14 @@ static void scsi_read_complete(void * opaque, int ret) * resulted in sense error but would need emulation. * In this case, emulate a valid VPD response. */ - if (s->needs_vpd_bl_emulation && + if (s->needs_vpd_bl_emulation && ret =3D=3D 0 && + (r->io_header.driver_status & SG_ERR_DRIVER_SENSE) && r->req.cmd.buf[0] =3D=3D INQUIRY && (r->req.cmd.buf[1] & 0x01) && r->req.cmd.buf[2] =3D=3D 0xb0) { - if (sg_io_sense_from_errno(-ret, &r->io_header, &sense)) { + SCSISense sense =3D + scsi_parse_sense_buf(r->req.sense, r->io_header.sb_len_wr); + if (sense.key =3D=3D ILLEGAL_REQUEST) { len =3D scsi_generic_emulate_block_limits(r, s); /* * No need to let scsi_read_complete go on and handle an --=20 1.8.3.1 From nobody Mon May 6 06:27:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541541248069134.5378970037491; Tue, 6 Nov 2018 13:54:08 -0800 (PST) Received: from localhost ([::1]:43935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9IV-0004Ps-0z for importer@patchew.org; Tue, 06 Nov 2018 16:54:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9Cr-0002lH-Fw for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:48:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK93U-0001I6-GZ for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:40 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:55902) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK93T-0000eE-Tu for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:36 -0500 Received: by mail-wm1-x334.google.com with SMTP id s10-v6so12270239wmc.5 for ; Tue, 06 Nov 2018 13:38:25 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id l186-v6sm3223526wma.13.2018.11.06.13.38.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:38:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=UXoBODQ4wFCYIlqvkFPG8T7sKKFLZ2kBSRrAKTUr30M=; b=peGNQ+ovJUcDjNAt5LnZDxxXBWhILu8wWVmblJ0LOmlrAtAfjjdYVPv/pDbMpV8SUA ujUnTNQhL2Or5BCZA7yycxP8+bkOI4nwmGgu+jYGx7bsaL+5Iv9jHQHRwQTn5vOjsORs IAD9N3uOPh62DUB4hqrfIRpYBXq/K+6rbu3KSebS4smI8Fj40FUbSSftI05k4ldUiBN3 KF/jH/DM9QPJzvB7VU1Y8+sbu5hCuWwADpa2ZtMHpuINjyGcLY5tF8SMzNTh1Gee6kbV /pTmKVsgn/znBCTStS/WAEUKxRkj2Mz7/k2LNk0/7TkNnPq5eypa9YBAvR+9wgIA8JZO 0v5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=UXoBODQ4wFCYIlqvkFPG8T7sKKFLZ2kBSRrAKTUr30M=; b=poy06HCn2sS39HpZRZ2A3qAE63ESIdeQDKZsKAAZl/RkvWg8oMxrgI34xq/f+sJxL0 GoP0q1e/TpyclaEsZWiV/KJiuU6uwwOt8Roq9x8o5X4xTP4bQFp5kexcEycJydNVzIp2 SE6DAkvoD8/YpeF72soWIiUeWq1iea9Ig120XTe/r5Y69nEMQeXeT9GppKg21802lBgz Y0V2i/L0ari8KBestDI7Fu1xURgKoyxfK22tEMMiv7ccjoJDY//dbH7NmUtq3/UssQgT zkq/P7YmsqSuHxyD7D268qf2tohbq85EuGj732azMf9GWGhlQcORcOC5enybvFqfpKZV XP5g== X-Gm-Message-State: AGRZ1gJGSDEXG99tMikOaFKgutITFgGDnB+tM2U//y7AESVKtCpoKawC XOKmxju7zhYjSP4UvQp2q95AAzRD X-Google-Smtp-Source: AJdET5fB9Xawmt4ln5W8pGj9zD25GWXX/kxvKUjAzDbxfre+wv2K7qRMM7U5AjVM1QxreGEQVgUgww== X-Received: by 2002:a1c:5447:: with SMTP id p7-v6mr664772wmi.129.1541540304212; Tue, 06 Nov 2018 13:38:24 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 22:38:02 +0100 Message-Id: <1541540283-45699-17-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> References: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::334 Subject: [Qemu-devel] [PULL 16/17] include/qemu/thread.h: Document qemu_thread_atexit* API X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Maydell Add documentation for the qemu_thread_atexit_add() and qemu_thread_atexit_remove() functions. We include a (previously undocumented) constraint that notifiers may not be called if a thread is exiting because the entire process is exiting. This is fine for our current use because the callers use it only for cleaning up resources which go away on process exit (memory, Win32 fibers), and we will need the flexibility for the new posix implementation. Signed-off-by: Peter Maydell Reviewed-by: Eric Blake Message-Id: <20181105135538.28025-2-peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini --- include/qemu/thread.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/qemu/thread.h b/include/qemu/thread.h index b2661b6..55d83a9 100644 --- a/include/qemu/thread.h +++ b/include/qemu/thread.h @@ -162,7 +162,29 @@ void qemu_thread_exit(void *retval); void qemu_thread_naming(bool enable); =20 struct Notifier; +/** + * qemu_thread_atexit_add: + * @notifier: Notifier to add + * + * Add the specified notifier to a list which will be run via + * notifier_list_notify() when this thread exits (either by calling + * qemu_thread_exit() or by returning from its start_routine). + * The usual usage is that the caller passes a Notifier which is + * a per-thread variable; it can then use the callback to free + * other per-thread data. + * + * If the thread exits as part of the entire process exiting, + * it is unspecified whether notifiers are called or not. + */ void qemu_thread_atexit_add(struct Notifier *notifier); +/** + * qemu_thread_atexit_remove: + * @notifier: Notifier to remove + * + * Remove the specified notifier from the thread-exit notification + * list. It is not valid to try to remove a notifier which is not + * on the list. + */ void qemu_thread_atexit_remove(struct Notifier *notifier); =20 struct QemuSpin { --=20 1.8.3.1 From nobody Mon May 6 06:27:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541541401671887.951713110368; Tue, 6 Nov 2018 13:56:41 -0800 (PST) Received: from localhost ([::1]:43955 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9Ky-0006Uh-9C for importer@patchew.org; Tue, 06 Nov 2018 16:56:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9Cq-0002qu-FI for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:48:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK93X-0001S7-1E for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:43 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:55904) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK93W-0000h8-41 for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:38 -0500 Received: by mail-wm1-x336.google.com with SMTP id s10-v6so12270266wmc.5 for ; Tue, 06 Nov 2018 13:38:26 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id l186-v6sm3223526wma.13.2018.11.06.13.38.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:38:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=7+axY70qcUOtqstSVvA5kHaZ7m2L8vni+JyNkUQ6rA0=; b=ngmzvmyWMLUKzM0bnKCFMNau+qIXxBx1spg+4qFIwxodqz9SXWCNY607eDorzjWHA7 i/Q0B0U52hYd5fzlxfwXKEEqkaTgW7p6ZbmAe9OeRxvD+T+hXQZR3mUdIt1we7zpIH6Y CYhwiHximIPSMr0+5avA/OjV/I4Yvvj2RVCp9Gw8+OrySPZO96v6PsI0RfM4XmABJNOs rj52mcA8M4xmSGBukuGtf/WVJMWVnSSrED9AoicrJ314Ul/mknFqXUFlobRbd1S8oE21 F4M2UwJ2Es0cGqttJbR+H8pbt7xp2mEXuPFbo5PfP6hgIOs3l6IBdKdA5vrpjS4uR/Ne Ndtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=7+axY70qcUOtqstSVvA5kHaZ7m2L8vni+JyNkUQ6rA0=; b=aqwSZmO7It5h1z5bAojvVtybWTO1Gh6h4OeLJtJEFP6SJi6sC5Mkzpq4DwZLmCnVMD smlXSHP7UE8sqgzcsccKmxg9bTQNC3WSvLafZWoC/7mntI21EDM90wC3P5lzz5PykL8O HOkVQXw3yVPrnptrOWyB9mE+hJW5PdJvjL9Xaq6Rcy724oh3CZdbmsKNvVsO80Fw5aQD ieK9+qoo7iUAEAD8GhNGiXi23Tgi0o/kcuZlHWocVIiTlcfNB1VM2UFLdoVyNs0NpFW5 rAl9KuQ3mVgLdh4i7m3A7DD7h/qwTMagVjakNKHppagk0NexS6nV9f4PFwd7+GR+wsSw TB+Q== X-Gm-Message-State: AGRZ1gIodhY1JNiMq3lWiEziKFZKXOx4iwpneX1ojQ6wh5q4qI+N48iS oa9PM2ghTYSY+WhZKzYCoxZvVet9 X-Google-Smtp-Source: AJdET5cFyInDWLXV5ZjxnyJ7UqGgEeALh3CbLNDZGd094rEZ3tRiNAqVrdbnHZq9BYKDZ8PTIuzOEw== X-Received: by 2002:a1c:9ed2:: with SMTP id h201-v6mr3358364wme.31.1541540305243; Tue, 06 Nov 2018 13:38:25 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 22:38:03 +0100 Message-Id: <1541540283-45699-18-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> References: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::336 Subject: [Qemu-devel] [PULL 17/17] util/qemu-thread-posix: Fix qemu_thread_atexit* for OSX X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Maydell Our current implementation of qemu_thread_atexit* is broken on OSX. This is because it works by cerating a piece of thread-specific data with pthread_key_create() and using the destructor function for that data to run the notifier function passed to it by the caller of qemu_thread_atexit_add(). The expected use case is that the caller uses a __thread variable as the notifier, and uses the callback to clean up information that it is keeping per-thread in __thread variables. Unfortunately, on OSX this does not work, because on OSX a __thread variable may be destroyed (freed) before the pthread_key_create() destructor runs. (POSIX imposes no ordering constraint here; the OSX implementation happens to implement __thread variables in terms of pthread_key_create((), whereas Linux uses different mechanisms that mean the __thread variables will still be present when the pthread_key_create() destructor is run.) Fix this by switching to a scheme similar to the one qemu-thread-win32 uses for qemu_thread_atexit: keep the thread's notifiers on a __thread variable, and run the notifiers on calls to qemu_thread_exit() and on return from the start routine passed to qemu_thread_start(). We do this with the pthread_cleanup_push() API. We take advantage of the qemu_thread_atexit_add() API permission not to run thread notifiers on process exit to avoid having to special case the main thread. Suggested-by: Paolo Bonzini Signed-off-by: Peter Maydell Reviewed-by: Eric Blake Message-Id: <20181105135538.28025-3-peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini --- util/qemu-thread-posix.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c index dfa66ff..865e476 100644 --- a/util/qemu-thread-posix.c +++ b/util/qemu-thread-posix.c @@ -443,42 +443,34 @@ void qemu_event_wait(QemuEvent *ev) } } =20 -static pthread_key_t exit_key; - -union NotifierThreadData { - void *ptr; - NotifierList list; -}; -QEMU_BUILD_BUG_ON(sizeof(union NotifierThreadData) !=3D sizeof(void *)); +static __thread NotifierList thread_exit; =20 +/* + * Note that in this implementation you can register a thread-exit + * notifier for the main thread, but it will never be called. + * This is OK because main thread exit can only happen when the + * entire process is exiting, and the API allows notifiers to not + * be called on process exit. + */ void qemu_thread_atexit_add(Notifier *notifier) { - union NotifierThreadData ntd; - ntd.ptr =3D pthread_getspecific(exit_key); - notifier_list_add(&ntd.list, notifier); - pthread_setspecific(exit_key, ntd.ptr); + notifier_list_add(&thread_exit, notifier); } =20 void qemu_thread_atexit_remove(Notifier *notifier) { - union NotifierThreadData ntd; - ntd.ptr =3D pthread_getspecific(exit_key); notifier_remove(notifier); - pthread_setspecific(exit_key, ntd.ptr); -} - -static void qemu_thread_atexit_run(void *arg) -{ - union NotifierThreadData ntd =3D { .ptr =3D arg }; - notifier_list_notify(&ntd.list, NULL); } =20 -static void __attribute__((constructor)) qemu_thread_atexit_init(void) +static void qemu_thread_atexit_notify(void *arg) { - pthread_key_create(&exit_key, qemu_thread_atexit_run); + /* + * Called when non-main thread exits (via qemu_thread_exit() + * or by returning from its start routine.) + */ + notifier_list_notify(&thread_exit, NULL); } =20 - typedef struct { void *(*start_routine)(void *); void *arg; @@ -490,6 +482,7 @@ static void *qemu_thread_start(void *args) QemuThreadArgs *qemu_thread_args =3D args; void *(*start_routine)(void *) =3D qemu_thread_args->start_routine; void *arg =3D qemu_thread_args->arg; + void *r; =20 #ifdef CONFIG_PTHREAD_SETNAME_NP /* Attempt to set the threads name; note that this is for debug, so @@ -501,7 +494,10 @@ static void *qemu_thread_start(void *args) #endif g_free(qemu_thread_args->name); g_free(qemu_thread_args); - return start_routine(arg); + pthread_cleanup_push(qemu_thread_atexit_notify, NULL); + r =3D start_routine(arg); + pthread_cleanup_pop(1); + return r; } =20 void qemu_thread_create(QemuThread *thread, const char *name, --=20 1.8.3.1