From patchwork Wed Jan 22 06:49:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 11345063 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C1CF86C1 for ; Wed, 22 Jan 2020 06:51:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 86CFC2253D for ; Wed, 22 Jan 2020 06:51:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UjWBxtHP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 86CFC2253D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9rG-0005wU-54 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jan 2020 01:51:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36003) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9pw-00049o-QY for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu9pv-0007k6-7M for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:00 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:44190 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iu9pv-0007jm-3G for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:49:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579675798; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Kg8dkgToII+17yCLdud4DGcpR3GxCmqyAmpoGaHxRIE=; b=UjWBxtHPiq3h0co2/Z7rB8M74l/31pfXWV4xI1bA0G4UCDH1VwoeKuqkpjMaZZhC16l1IC pRtFWTY/D81hXUCGD/tlRei3609A5r0m/lVSfqzDXJlzUfyv1VUpQQe0g/HzV3D+D6y3cS vdPRxo2LerSGp/jCdV0BofXD9S0fArA= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-210-MJLSIS9dMASv-ZX0XqHiYw-1; Wed, 22 Jan 2020 01:49:56 -0500 Received: by mail-wr1-f70.google.com with SMTP id f17so2597902wrt.19 for ; Tue, 21 Jan 2020 22:49:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SZlgsbuRexepbyzGOJZSIRK1RX+EEBHf43p6wbErIqU=; b=F91s4/SpO9FUDaCC95+4rq8W6RA/oPdLZSF1Bs6cDSweUkamt6FbWZlPFjrjiyxase LKKZUMG27hca7wWom1oGlBGanBPC0KVUsyCyY9EF9wUM8yzaymvVdYb1z6MW2FJ9CQBc 2oWeuMu/UnwLlwEwvdgfjOEY2MMgELXhlU8TjmLU+4HicKOoDLpb+sf4jzvZwE5AnEP/ TRYmZtu5TDglqRvc8FEggdcyE8CBvlZTdgDeOhufy/4tWCBkKgsbrFpTHOPe3lH/RBk4 V0ZwOwyBrggm86xXQesXyj+FA7met99eg3igVd7uumkiEthb7qcCuZfMccTIDBpI3jBu bG0Q== X-Gm-Message-State: APjAAAVle50xU7QRdA6VESdRu15ulMtUTfL0IVXZe5hcKnzD3j8aANh9 2GfLM8XJdx/cwYVAR0/S8rdlSHGg9B3q+CycCokWENj+Z90mUkdwSE74B8Fr8NfwVYhdGKRZSW9 STqTyD6OGhJfKkXw= X-Received: by 2002:a1c:1d8c:: with SMTP id d134mr1236673wmd.16.1579675794306; Tue, 21 Jan 2020 22:49:54 -0800 (PST) X-Google-Smtp-Source: APXvYqx7udfMfciSpbqYq8Nv/y4uCgJdMCwRZA12W27Y/k3SsuF4R/FkiomsMQ6MHXo8racZehLT5Q== X-Received: by 2002:a1c:1d8c:: with SMTP id d134mr1236639wmd.16.1579675793970; Tue, 21 Jan 2020 22:49:53 -0800 (PST) Received: from redhat.com (bzq-79-176-0-156.red.bezeqint.net. [79.176.0.156]) by smtp.gmail.com with ESMTPSA id z11sm159844wmg.30.2020.01.21.22.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 22:49:53 -0800 (PST) Date: Wed, 22 Jan 2020 01:49:51 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 01/17] q35: implement 128K SMRAM at default SMBASE address Message-ID: <20200122064907.512501-2-mst@redhat.com> References: <20200122064907.512501-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200122064907.512501-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: MJLSIS9dMASv-ZX0XqHiYw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Igor Mammedov , Paolo Bonzini , Laszlo Ersek , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov It's not what real HW does, implementing which would be overkill [**] and would require complex cross stack changes (QEMU+firmware) to make it work. So considering that SMRAM is owned by MCH, for simplicity (ab)use reserved Q35 register, which allows QEMU and firmware easily init and make RAM at SMBASE available only from SMM context. Patch uses commit (2f295167e0 q35/mch: implement extended TSEG sizes) for inspiration and uses reserved register in config space at 0x9c offset [*] to extend q35 pci-host with ability to use 128K at 0x30000 as SMRAM and hide it (like TSEG) from non-SMM context. Usage: 1: write 0xff in the register 2: if the feature is supported, follow up read from the register should return 0x01. At this point RAM at 0x30000 is still available for SMI handler configuration from non-SMM context 3: writing 0x02 in the register, locks SMBASE area, making its contents available only from SMM context. In non-SMM context, reads return 0xff and writes are ignored. Further writes into the register are ignored until the system reset. *) https://www.mail-archive.com/qemu-devel@nongnu.org/msg455991.html **) https://www.mail-archive.com/qemu-devel@nongnu.org/msg646965.html Signed-off-by: Igor Mammedov Message-Id: <1575896942-331151-3-git-send-email-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Tested-by: Laszlo Ersek --- include/hw/pci-host/q35.h | 10 +++++ hw/i386/pc.c | 4 +- hw/pci-host/q35.c | 84 +++++++++++++++++++++++++++++++++++---- 3 files changed, 90 insertions(+), 8 deletions(-) diff --git a/include/hw/pci-host/q35.h b/include/hw/pci-host/q35.h index b3bcf2e632..976fbae599 100644 --- a/include/hw/pci-host/q35.h +++ b/include/hw/pci-host/q35.h @@ -32,6 +32,7 @@ #include "hw/acpi/ich9.h" #include "hw/pci-host/pam.h" #include "hw/i386/intel_iommu.h" +#include "qemu/units.h" #define TYPE_Q35_HOST_DEVICE "q35-pcihost" #define Q35_HOST_DEVICE(obj) \ @@ -54,6 +55,8 @@ typedef struct MCHPCIState { MemoryRegion smram_region, open_high_smram; MemoryRegion smram, low_smram, high_smram; MemoryRegion tseg_blackhole, tseg_window; + MemoryRegion smbase_blackhole, smbase_window; + bool has_smram_at_smbase; Range pci_hole; uint64_t below_4g_mem_size; uint64_t above_4g_mem_size; @@ -97,6 +100,13 @@ typedef struct Q35PCIHost { #define MCH_HOST_BRIDGE_EXT_TSEG_MBYTES_QUERY 0xffff #define MCH_HOST_BRIDGE_EXT_TSEG_MBYTES_MAX 0xfff +#define MCH_HOST_BRIDGE_SMBASE_SIZE (128 * KiB) +#define MCH_HOST_BRIDGE_SMBASE_ADDR 0x30000 +#define MCH_HOST_BRIDGE_F_SMBASE 0x9c +#define MCH_HOST_BRIDGE_F_SMBASE_QUERY 0xff +#define MCH_HOST_BRIDGE_F_SMBASE_IN_RAM 0x01 +#define MCH_HOST_BRIDGE_F_SMBASE_LCK 0x02 + #define MCH_HOST_BRIDGE_PCIEXBAR 0x60 /* 64bit register */ #define MCH_HOST_BRIDGE_PCIEXBAR_SIZE 8 /* 64bit register */ #define MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT 0xb0000000 diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 8054bc4147..a6302a772d 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -93,7 +93,9 @@ #include "fw_cfg.h" #include "trace.h" -GlobalProperty pc_compat_4_2[] = {}; +GlobalProperty pc_compat_4_2[] = { + { "mch", "smbase-smram", "off" }, +}; const size_t pc_compat_4_2_len = G_N_ELEMENTS(pc_compat_4_2); GlobalProperty pc_compat_4_1[] = {}; diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index 158d270b9f..6342f73b9f 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -275,20 +275,20 @@ static const TypeInfo q35_host_info = { * MCH D0:F0 */ -static uint64_t tseg_blackhole_read(void *ptr, hwaddr reg, unsigned size) +static uint64_t blackhole_read(void *ptr, hwaddr reg, unsigned size) { return 0xffffffff; } -static void tseg_blackhole_write(void *opaque, hwaddr addr, uint64_t val, - unsigned width) +static void blackhole_write(void *opaque, hwaddr addr, uint64_t val, + unsigned width) { /* nothing */ } -static const MemoryRegionOps tseg_blackhole_ops = { - .read = tseg_blackhole_read, - .write = tseg_blackhole_write, +static const MemoryRegionOps blackhole_ops = { + .read = blackhole_read, + .write = blackhole_write, .endianness = DEVICE_NATIVE_ENDIAN, .valid.min_access_size = 1, .valid.max_access_size = 4, @@ -430,6 +430,46 @@ static void mch_update_ext_tseg_mbytes(MCHPCIState *mch) } } +static void mch_update_smbase_smram(MCHPCIState *mch) +{ + PCIDevice *pd = PCI_DEVICE(mch); + uint8_t *reg = pd->config + MCH_HOST_BRIDGE_F_SMBASE; + bool lck; + + if (!mch->has_smram_at_smbase) { + return; + } + + if (*reg == MCH_HOST_BRIDGE_F_SMBASE_QUERY) { + pd->wmask[MCH_HOST_BRIDGE_F_SMBASE] = + MCH_HOST_BRIDGE_F_SMBASE_LCK; + *reg = MCH_HOST_BRIDGE_F_SMBASE_IN_RAM; + return; + } + + /* + * default/reset state, discard written value + * which will disable SMRAM balackhole at SMBASE + */ + if (pd->wmask[MCH_HOST_BRIDGE_F_SMBASE] == 0xff) { + *reg = 0x00; + } + + memory_region_transaction_begin(); + if (*reg & MCH_HOST_BRIDGE_F_SMBASE_LCK) { + /* disable all writes */ + pd->wmask[MCH_HOST_BRIDGE_F_SMBASE] &= + ~MCH_HOST_BRIDGE_F_SMBASE_LCK; + *reg = MCH_HOST_BRIDGE_F_SMBASE_LCK; + lck = true; + } else { + lck = false; + } + memory_region_set_enabled(&mch->smbase_blackhole, lck); + memory_region_set_enabled(&mch->smbase_window, lck); + memory_region_transaction_commit(); +} + static void mch_write_config(PCIDevice *d, uint32_t address, uint32_t val, int len) { @@ -456,6 +496,10 @@ static void mch_write_config(PCIDevice *d, MCH_HOST_BRIDGE_EXT_TSEG_MBYTES_SIZE)) { mch_update_ext_tseg_mbytes(mch); } + + if (ranges_overlap(address, len, MCH_HOST_BRIDGE_F_SMBASE, 1)) { + mch_update_smbase_smram(mch); + } } static void mch_update(MCHPCIState *mch) @@ -464,6 +508,7 @@ static void mch_update(MCHPCIState *mch) mch_update_pam(mch); mch_update_smram(mch); mch_update_ext_tseg_mbytes(mch); + mch_update_smbase_smram(mch); /* * pci hole goes from end-of-low-ram to io-apic. @@ -514,6 +559,9 @@ static void mch_reset(DeviceState *qdev) MCH_HOST_BRIDGE_EXT_TSEG_MBYTES_QUERY); } + d->config[MCH_HOST_BRIDGE_F_SMBASE] = 0; + d->wmask[MCH_HOST_BRIDGE_F_SMBASE] = 0xff; + mch_update(mch); } @@ -563,7 +611,7 @@ static void mch_realize(PCIDevice *d, Error **errp) memory_region_add_subregion(&mch->smram, 0xfeda0000, &mch->high_smram); memory_region_init_io(&mch->tseg_blackhole, OBJECT(mch), - &tseg_blackhole_ops, NULL, + &blackhole_ops, NULL, "tseg-blackhole", 0); memory_region_set_enabled(&mch->tseg_blackhole, false); memory_region_add_subregion_overlap(mch->system_memory, @@ -575,6 +623,27 @@ static void mch_realize(PCIDevice *d, Error **errp) memory_region_set_enabled(&mch->tseg_window, false); memory_region_add_subregion(&mch->smram, mch->below_4g_mem_size, &mch->tseg_window); + + /* + * This is not what hardware does, so it's QEMU specific hack. + * See commit message for details. + */ + memory_region_init_io(&mch->smbase_blackhole, OBJECT(mch), &blackhole_ops, + NULL, "smbase-blackhole", + MCH_HOST_BRIDGE_SMBASE_SIZE); + memory_region_set_enabled(&mch->smbase_blackhole, false); + memory_region_add_subregion_overlap(mch->system_memory, + MCH_HOST_BRIDGE_SMBASE_ADDR, + &mch->smbase_blackhole, 1); + + memory_region_init_alias(&mch->smbase_window, OBJECT(mch), + "smbase-window", mch->ram_memory, + MCH_HOST_BRIDGE_SMBASE_ADDR, + MCH_HOST_BRIDGE_SMBASE_SIZE); + memory_region_set_enabled(&mch->smbase_window, false); + memory_region_add_subregion(&mch->smram, MCH_HOST_BRIDGE_SMBASE_ADDR, + &mch->smbase_window); + object_property_add_const_link(qdev_get_machine(), "smram", OBJECT(&mch->smram), &error_abort); @@ -601,6 +670,7 @@ uint64_t mch_mcfg_base(void) static Property mch_props[] = { DEFINE_PROP_UINT16("extended-tseg-mbytes", MCHPCIState, ext_tseg_mbytes, 16), + DEFINE_PROP_BOOL("smbase-smram", MCHPCIState, has_smram_at_smbase, true), DEFINE_PROP_END_OF_LIST(), }; From patchwork Wed Jan 22 06:49:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 11345065 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C2796C1 for ; Wed, 22 Jan 2020 06:51:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6F8F02253D for ; Wed, 22 Jan 2020 06:51:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SmXO31Vl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F8F02253D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9rM-00065E-8T for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jan 2020 01:51:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36014) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9pz-0004BL-FP for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu9py-0007ln-6y for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:03 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:29451 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iu9py-0007lW-3A for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579675801; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gDntRjnqkdZXlC1JZeGY/cuEoEt7aTCjD9wGxlyp8Vo=; b=SmXO31Vl4fDKrsKcNV7a7mqHNOYKBmcV+izLp4vqsTjslx6UMwk0hQ1wRd9iAb3zqs+tXz kfL9cVBLASLFwkGJJO82POyTXHSR/AN3s5BlPlPmaKqFacoABgzpALY5mtNFqiEg6wXU/Z T573WsnNG/W8FaYSvCtznNzvupRuicg= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-416-J74QtcqLM5yMbq1W3TlZRw-1; Wed, 22 Jan 2020 01:49:58 -0500 Received: by mail-wm1-f70.google.com with SMTP id y125so1198709wmg.1 for ; Tue, 21 Jan 2020 22:49:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=o0n2DkkmVlJvF/kJjOaBKtOGbZzvtHQ/1x2pWKeDMgM=; b=aqriCnkQKpnajKP9mXa5IYKIk2mj+WubffQh1U/9YZcPfAI6jftld5QSRsnIE+ymPY vACubJiPPe+Ers6oIn9OYT0ylcgSz19Z6uMRm7iBcrY47oapsINrArlW3f7ffvKoB/IN uBTQzL4USw53b1DFlojWc29hGPQLar9m9DPxgX3rlFAHKFkSjFP4js975itbpUFLhJlq nVLbmgHSEBvNFtHjy+hDGaBpC4XTjAyXFlalCwE8E9Dk8lfBueentKckhdTGgiWQf3de lx3HZBEEwSwYpgm0978jNr3FkcwInymh0YD5Q6Z4Wp/N73y4nvNXuv6FFZgvoQrcdM9X +UKw== X-Gm-Message-State: APjAAAUxArFssmLB54ctJ1AvW4Bt46hmRI+4Ae1w3nd5VvmmYLhUerNu HMo/wLstL4unExxFtvHmMzzXx5cjj/HULlIkzlUHARspsHXsrwuxaY18hlaEfCcaNJ7kvWo6Y0d 8qNyCjoxcFR1lYK8= X-Received: by 2002:a05:600c:295a:: with SMTP id n26mr1165078wmd.187.1579675797051; Tue, 21 Jan 2020 22:49:57 -0800 (PST) X-Google-Smtp-Source: APXvYqz7lNdKQRvFMYzuaNRNe5P9x+q7sqeW7xFV4t1tmTPZcMgS0CvmaoiTFVp8t3jqVRgkfhH7aw== X-Received: by 2002:a05:600c:295a:: with SMTP id n26mr1165060wmd.187.1579675796807; Tue, 21 Jan 2020 22:49:56 -0800 (PST) Received: from redhat.com (bzq-79-176-0-156.red.bezeqint.net. [79.176.0.156]) by smtp.gmail.com with ESMTPSA id k11sm2542585wmc.20.2020.01.21.22.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 22:49:56 -0800 (PST) Date: Wed, 22 Jan 2020 01:49:54 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 02/17] tests: q35: MCH: add default SMBASE SMRAM lock test Message-ID: <20200122064907.512501-3-mst@redhat.com> References: <20200122064907.512501-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200122064907.512501-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: J74QtcqLM5yMbq1W3TlZRw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Paolo Bonzini , Igor Mammedov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov test lockable SMRAM at default SMBASE feature, introduced by patch "q35: implement 128K SMRAM at default SMBASE address" Signed-off-by: Igor Mammedov Message-Id: <1575899217-333105-1-git-send-email-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/q35-test.c | 105 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/tests/qtest/q35-test.c b/tests/qtest/q35-test.c index a68183d513..c922d81bc0 100644 --- a/tests/qtest/q35-test.c +++ b/tests/qtest/q35-test.c @@ -186,6 +186,109 @@ static void test_tseg_size(const void *data) qtest_quit(qts); } +#define SMBASE 0x30000 +#define SMRAM_TEST_PATTERN 0x32 +#define SMRAM_TEST_RESET_PATTERN 0x23 + +static void test_smram_smbase_lock(void) +{ + QPCIBus *pcibus; + QPCIDevice *pcidev; + QDict *response; + QTestState *qts; + int i; + + qts = qtest_init("-M q35"); + + pcibus = qpci_new_pc(qts, NULL); + g_assert(pcibus != NULL); + + pcidev = qpci_device_find(pcibus, 0); + g_assert(pcidev != NULL); + + /* check that SMRAM is not enabled by default */ + g_assert(qpci_config_readb(pcidev, MCH_HOST_BRIDGE_F_SMBASE) == 0); + qtest_writeb(qts, SMBASE, SMRAM_TEST_PATTERN); + g_assert_cmpint(qtest_readb(qts, SMBASE), ==, SMRAM_TEST_PATTERN); + + /* check that writing junk to 0x9c before before negotiating is ignored */ + for (i = 0; i < 0xff; i++) { + qpci_config_writeb(pcidev, MCH_HOST_BRIDGE_F_SMBASE, i); + g_assert(qpci_config_readb(pcidev, MCH_HOST_BRIDGE_F_SMBASE) == 0); + } + + /* enable SMRAM at SMBASE */ + qpci_config_writeb(pcidev, MCH_HOST_BRIDGE_F_SMBASE, 0xff); + g_assert(qpci_config_readb(pcidev, MCH_HOST_BRIDGE_F_SMBASE) == 0x01); + /* lock SMRAM at SMBASE */ + qpci_config_writeb(pcidev, MCH_HOST_BRIDGE_F_SMBASE, 0x02); + g_assert(qpci_config_readb(pcidev, MCH_HOST_BRIDGE_F_SMBASE) == 0x02); + + /* check that SMRAM at SMBASE is locked and can't be unlocked */ + g_assert_cmpint(qtest_readb(qts, SMBASE), ==, 0xff); + for (i = 0; i <= 0xff; i++) { + /* make sure register is immutable */ + qpci_config_writeb(pcidev, MCH_HOST_BRIDGE_F_SMBASE, i); + g_assert(qpci_config_readb(pcidev, MCH_HOST_BRIDGE_F_SMBASE) == 0x02); + + /* RAM access should go into black hole */ + qtest_writeb(qts, SMBASE, SMRAM_TEST_PATTERN); + g_assert_cmpint(qtest_readb(qts, SMBASE), ==, 0xff); + } + + /* reset */ + response = qtest_qmp(qts, "{'execute': 'system_reset', 'arguments': {} }"); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + qobject_unref(response); + + /* check RAM at SMBASE is available after reset */ + g_assert_cmpint(qtest_readb(qts, SMBASE), ==, SMRAM_TEST_PATTERN); + g_assert(qpci_config_readb(pcidev, MCH_HOST_BRIDGE_F_SMBASE) == 0); + qtest_writeb(qts, SMBASE, SMRAM_TEST_RESET_PATTERN); + g_assert_cmpint(qtest_readb(qts, SMBASE), ==, SMRAM_TEST_RESET_PATTERN); + + g_free(pcidev); + qpci_free_pc(pcibus); + + qtest_quit(qts); +} + +static void test_without_smram_base(void) +{ + QPCIBus *pcibus; + QPCIDevice *pcidev; + QTestState *qts; + int i; + + qts = qtest_init("-M pc-q35-4.1"); + + pcibus = qpci_new_pc(qts, NULL); + g_assert(pcibus != NULL); + + pcidev = qpci_device_find(pcibus, 0); + g_assert(pcidev != NULL); + + /* check that RAM is accessible */ + qtest_writeb(qts, SMBASE, SMRAM_TEST_PATTERN); + g_assert_cmpint(qtest_readb(qts, SMBASE), ==, SMRAM_TEST_PATTERN); + + /* check that writing to 0x9c succeeds */ + for (i = 0; i <= 0xff; i++) { + qpci_config_writeb(pcidev, MCH_HOST_BRIDGE_F_SMBASE, i); + g_assert(qpci_config_readb(pcidev, MCH_HOST_BRIDGE_F_SMBASE) == i); + } + + /* check that RAM is still accessible */ + qtest_writeb(qts, SMBASE, SMRAM_TEST_PATTERN + 1); + g_assert_cmpint(qtest_readb(qts, SMBASE), ==, (SMRAM_TEST_PATTERN + 1)); + + g_free(pcidev); + qpci_free_pc(pcibus); + + qtest_quit(qts); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); @@ -197,5 +300,7 @@ int main(int argc, char **argv) qtest_add_data_func("/q35/tseg-size/8mb", &tseg_8mb, test_tseg_size); qtest_add_data_func("/q35/tseg-size/ext/16mb", &tseg_ext_16mb, test_tseg_size); + qtest_add_func("/q35/smram/smbase_lock", test_smram_smbase_lock); + qtest_add_func("/q35/smram/legacy_smbase", test_without_smram_base); return g_test_run(); } From patchwork Wed Jan 22 06:49:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 11345067 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9F78C6C1 for ; Wed, 22 Jan 2020 06:51:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 73D632253D for ; Wed, 22 Jan 2020 06:51:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XKPCECOI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73D632253D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9rQ-00069M-3x for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jan 2020 01:51:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36025) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9q1-0004Dm-8C for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu9q0-0007mp-0y for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:05 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:35789 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iu9pz-0007mN-U2 for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579675803; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OhMnOXw2jltLb3g6o0bZN0GY8d9d1JsgKnb3ojyU5uY=; b=XKPCECOIYCNN5ELf1rOb4s8RxaUTT5BZzpU4C06ngcrAAPfuuTYM2v5oscFtf8jbmKEPqL fKYs4lfE7JcPJkvPTbgV6dMGNUuMAG7DhFZs6qPsTSASK1AOAsNO7cH+x0RcmUn5RjSE2o 7i9T2YTpZzV8RlL/HKHcUSvhcenH/3k= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-181-5o02YcEENCSAkhOHlraSHQ-1; Wed, 22 Jan 2020 01:50:01 -0500 Received: by mail-wr1-f69.google.com with SMTP id c17so2593422wrp.10 for ; Tue, 21 Jan 2020 22:50:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SmP96JjZ61jUtUgNUruj35mPI4zb3UYO5pk5xajyjow=; b=DWwcm1HA9DS/L4CBCy06jTCqwxbY1BE512YlXHEgXvnBZe6X63KQtu4JMtNIjHNweX R2JJN3b3IiOG3rtWsGCYZtuOU5whC1VBTxZoFdSU+Nk41jJJ+I5s2t2C0X9p5agxI2aG GDcW6xgogF/yzOLfn5CRS9qIjbuWqZ0HLUCKPv/yf3C+8RZx6k7sYEmvSsQJpMw6w+Gc h6vVymveFYZvD5n3bQg8sz1s898bbqQXffC3BMUe9WEShpeUdaSUFXZe9ADslrpd2S8r 0hslTzPnGPekFyz7lR5mwOsuO6EwQLJ0Bc3Vx3m2eXLx3Qa3Mgmxe8oqGS6RUMeT3hI1 AF8A== X-Gm-Message-State: APjAAAWJL3fRWWAgkZmvcYmwqc4/7H8UUwF7DkU7XABti82PvUNXPjrc g5qE1XaEY0qwOtiofLlsiN+MXM64QBCyKeR0tKVPRkzuuIB5b3KTcCkjTpXLrXj9YlcW6bQdRXt 3qx2rGA13YpLXJdg= X-Received: by 2002:a5d:6a02:: with SMTP id m2mr9301023wru.52.1579675799777; Tue, 21 Jan 2020 22:49:59 -0800 (PST) X-Google-Smtp-Source: APXvYqz/z4TBfVfpzHdyQUXU8UAQxjV4KrXxGxYxakvbRkT1DN4c8z2JdmwGrjJqoE32nvTFYJqpcw== X-Received: by 2002:a5d:6a02:: with SMTP id m2mr9301007wru.52.1579675799548; Tue, 21 Jan 2020 22:49:59 -0800 (PST) Received: from redhat.com (bzq-79-176-0-156.red.bezeqint.net. [79.176.0.156]) by smtp.gmail.com with ESMTPSA id c9sm1926408wme.41.2020.01.21.22.49.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 22:49:59 -0800 (PST) Date: Wed, 22 Jan 2020 01:49:57 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 03/17] acpi: cpuhp: spec: clarify 'CPU selector' register usage and endianness Message-ID: <20200122064907.512501-4-mst@redhat.com> References: <20200122064907.512501-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200122064907.512501-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 5o02YcEENCSAkhOHlraSHQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Laszlo Ersek , Igor Mammedov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov * Move reserved registers to the top of the section, so reader would be aware of effects when reading registers description. * State registers endianness explicitly at the beginning of the section * Describe registers behavior in case of 'CPU selector' register contains value that doesn't point to a possible CPU. Signed-off-by: Igor Mammedov Reviewed-by: Laszlo Ersek Message-Id: <1575896942-331151-5-git-send-email-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/specs/acpi_cpu_hotplug.txt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/specs/acpi_cpu_hotplug.txt b/docs/specs/acpi_cpu_hotplug.txt index ee219c8358..4e65286ff5 100644 --- a/docs/specs/acpi_cpu_hotplug.txt +++ b/docs/specs/acpi_cpu_hotplug.txt @@ -30,6 +30,18 @@ Register block base address: Register block size: ACPI_CPU_HOTPLUG_REG_LEN = 12 +All accesses to registers described below, imply little-endian byte order. + +Reserved resisters behavior: + - write accesses are ignored + - read accesses return all bits set to 0. + +The last stored value in 'CPU selector' must refer to a possible CPU, otherwise + - reads from any register return 0 + - writes to any other register are ignored until valid value is stored into it +On QEMU start, 'CPU selector' is initialized to a valid value, on reset it +keeps the current value. + read access: offset: [0x0-0x3] reserved @@ -86,9 +98,3 @@ write access: ACPI_DEVICE_OST QMP event from QEMU to external applications with current values of OST event and status registers. other values: reserved - -Selecting CPU device beyond possible range has no effect on platform: - - write accesses to CPU hot-plug registers not documented above are - ignored - - read accesses to CPU hot-plug registers not documented above return - all bits set to 0. From patchwork Wed Jan 22 06:50:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 11345079 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 735A66C1 for ; Wed, 22 Jan 2020 06:54:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4A13524655 for ; Wed, 22 Jan 2020 06:54:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PFwiq6GB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A13524655 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9tx-0001FD-Rs for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jan 2020 01:54:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36037) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9q3-0004GL-CW for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu9q2-0007o0-6n for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:07 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:52558 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iu9q2-0007nm-3j for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579675805; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZL7cOBRrNjS5xV9Me0lJk0ipNP0N1056GF7w4b0GCrQ=; b=PFwiq6GBd1VFjMQrK6TVPJ4L/4HdWTMoNVB4sRHMJS4A69it/49wxIL2dkTQxawd8G4olq 0KieIj8mqB2V/uxM0i15o7xAPyWPYoryns75/qH/Jlmx+D6xcCMdpzPjT22ZlBxItYQm15 umT/zAMQhMAC9gZsuETHSnf50U7Vkg0= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-117-Xoc7q06rPpmklxhoyTu_Mg-1; Wed, 22 Jan 2020 01:50:03 -0500 Received: by mail-wr1-f72.google.com with SMTP id k18so2612902wrw.9 for ; Tue, 21 Jan 2020 22:50:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=0NReYyn4JQkVdN7PoAGTBso0lphxyHmehPnh64blNL8=; b=J+ca0WCLtDcx5h79tGeB7yygDq0xnyUDsyWwAFQICvtk4Vh8wgZkMl90tsHrDQJJ5x sid7VU/+aKbhcvh7kLEtFzzGvuB7u4nW6/YoyqPyNx/1IyD6pjN4IhGgh7e7Gl7m8isc lXJ07AeGmYg1q4Pu4B01S81e61hEdICoR0FbWLEwnlPE4lyEvND+Og0GWrzM5hiLKXq2 SSddwG9Axg098iGoDuJ9TYATq7US6lqefvbBXNQGJ095Zk3SpCVn6v/NxzRDEMdQpUKJ +F+YNo1YHLUB04fXD7tAENVMMz1NxWCeySyR5XjGxtXPfsMyTf2AH5Sp2Vjf2xBAprLk em6g== X-Gm-Message-State: APjAAAUmGbBFQ+ciky+XtFsOv9Ur4/VUmIv7i64RIHYk44/f8y6FpHlq asQEz9IctmZ75Mb1/lm9b3r+HFMbOnReCBPtlVzFjBEx6JJ0ZMSMM80pdg4F45rX54aFM6IZQtx OSVW7ekQvNSHTTxs= X-Received: by 2002:a5d:6987:: with SMTP id g7mr9012025wru.422.1579675802438; Tue, 21 Jan 2020 22:50:02 -0800 (PST) X-Google-Smtp-Source: APXvYqz2OTrpQoMnscysa7K5/ivHhpeRPioT4Fg9oVUKRCAOy/kjGECDU3cD4xp145Gom1xRaWLcvw== X-Received: by 2002:a5d:6987:: with SMTP id g7mr9012009wru.422.1579675802252; Tue, 21 Jan 2020 22:50:02 -0800 (PST) Received: from redhat.com (bzq-79-176-0-156.red.bezeqint.net. [79.176.0.156]) by smtp.gmail.com with ESMTPSA id t12sm55393616wrs.96.2020.01.21.22.50.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 22:50:01 -0800 (PST) Date: Wed, 22 Jan 2020 01:50:00 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 04/17] acpi: cpuhp: spec: fix 'Command data' description Message-ID: <20200122064907.512501-5-mst@redhat.com> References: <20200122064907.512501-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200122064907.512501-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: Xoc7q06rPpmklxhoyTu_Mg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Laszlo Ersek , Igor Mammedov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov Correct returned value description in case 'Command field' == 0x0, it's not PXM but CPU selector value with pending event In addition describe 0 blanket value in case of not supported 'Command field' value. Signed-off-by: Igor Mammedov Reviewed-by: Laszlo Ersek Message-Id: <1575896942-331151-6-git-send-email-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/specs/acpi_cpu_hotplug.txt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/specs/acpi_cpu_hotplug.txt b/docs/specs/acpi_cpu_hotplug.txt index 4e65286ff5..d5108720bf 100644 --- a/docs/specs/acpi_cpu_hotplug.txt +++ b/docs/specs/acpi_cpu_hotplug.txt @@ -56,9 +56,8 @@ read access: 3-7: reserved and should be ignored by OSPM [0x5-0x7] reserved [0x8] Command data: (DWORD access) - in case of error or unsupported command reads is 0xFFFFFFFF - current 'Command field' value: - 0: returns PXM value corresponding to device + contains 0 unless value last stored in 'Command field' is one of: + 0: contains 'CPU selector' value of a CPU with pending event[s] write access: offset: @@ -81,9 +80,9 @@ write access: value: 0: selects a CPU device with inserting/removing events and following reads from 'Command data' register return - selected CPU (CPU selector value). If no CPU with events - found, the current CPU selector doesn't change and - corresponding insert/remove event flags are not set. + selected CPU ('CPU selector' value). + If no CPU with events found, the current 'CPU selector' doesn't + change and corresponding insert/remove event flags are not modified. 1: following writes to 'Command data' register set OST event register in QEMU 2: following writes to 'Command data' register set OST status From patchwork Wed Jan 22 06:50:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 11345073 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 518B21580 for ; Wed, 22 Jan 2020 06:53:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2798E24656 for ; Wed, 22 Jan 2020 06:53:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eFrPRBGe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2798E24656 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9td-0000hj-SI for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jan 2020 01:53:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36052) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9q6-0004KM-6f for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu9q5-0007q6-6P for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:10 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:39481 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iu9q5-0007pl-3O for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579675808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=47oh9akmDrhkEtMoFDskPeBdfNDdFnGRT7tngWCeWTo=; b=eFrPRBGegOtqOUhjyVNZz7tUw3HNxrM3gviycmYHrwcmacuOAlAHq2WIj3vP9n2ibZgx+2 hU7Xuj9LSLECeeAA6gU5/rU9G7pmpnJ4nBhO5x37ataKh5nxFcFNYeGsXKLkx642THZRaI 2iBwv7vzastxjvsb3TQIlWwhKE4cdMg= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-309-9ET7OsDCOMmDQg297eLG7A-1; Wed, 22 Jan 2020 01:50:06 -0500 Received: by mail-wm1-f70.google.com with SMTP id b133so123665wmb.2 for ; Tue, 21 Jan 2020 22:50:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=qLwCkCIBdxpEX8Qu8xH9v4eZQ8D42cjdHR7wkseYBRA=; b=RWo80zUtA6fKi2MUOLtDClQxdRKC2J4IeEKkaNaHDWsZaJT/ATEML+pwr3qi7uBX0b vJpppNfuesx8d6sZPQQvYe0C7mrSoWzEqqde4F5NXxTBaq9PjQtJyx2D1ObWiZQG93/Q Vde4Cf75hnJpyaNthndPAHH6GuyuwAUkbKwvYsf6mNxY6M+d+wxGkgyMdw+tRCJTqlat /HOxuCXjYEdYHD49V5zN/LgOFlhNOMO4eyIRNTVEHoO0e+Ph4jYj+YlLLsNEiwnzO3+q xpE0ZKsTfklawfVMJvvaCF1G4a3oH96WWzPbF36lN9vqrZoSuuteN7l2hV6LW0xdSTHj 9n8w== X-Gm-Message-State: APjAAAX/3i0TlHPqjBDTmemgefxZ0+++FQJTpH90Uxkxa3b4uA+d1N+K ElVwKfLiIRjJ0qg88A3cVKA/maeVm+Mw3NSi9ylFXdlskt5zaxtagD/6+16vY6ARly35WiVq7LU Gep+Vxh/6r9LFYI8= X-Received: by 2002:adf:ee11:: with SMTP id y17mr8973809wrn.425.1579675805272; Tue, 21 Jan 2020 22:50:05 -0800 (PST) X-Google-Smtp-Source: APXvYqwvIVRA2Q1iB2VjDQmReIAFRqgVHEms5wDpG3HXrqhCL35GuzKqpzikCS+Wby4B4KkpDl5HUA== X-Received: by 2002:adf:ee11:: with SMTP id y17mr8973795wrn.425.1579675805103; Tue, 21 Jan 2020 22:50:05 -0800 (PST) Received: from redhat.com (bzq-79-176-0-156.red.bezeqint.net. [79.176.0.156]) by smtp.gmail.com with ESMTPSA id i10sm56890840wru.16.2020.01.21.22.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 22:50:04 -0800 (PST) Date: Wed, 22 Jan 2020 01:50:02 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 05/17] acpi: cpuhp: spec: clarify store into 'Command data' when 'Command field' == 0 Message-ID: <20200122064907.512501-6-mst@redhat.com> References: <20200122064907.512501-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200122064907.512501-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 9ET7OsDCOMmDQg297eLG7A-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Laszlo Ersek , Igor Mammedov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov Write section of 'Command data' register should describe what happens when it's written into. Correct description in case the last stored 'Command field' value is equal to 0, to reflect that currently it's not supported. Signed-off-by: Igor Mammedov Reviewed-by: Laszlo Ersek Message-Id: <1575896942-331151-7-git-send-email-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/specs/acpi_cpu_hotplug.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/specs/acpi_cpu_hotplug.txt b/docs/specs/acpi_cpu_hotplug.txt index d5108720bf..8fb9ad22e6 100644 --- a/docs/specs/acpi_cpu_hotplug.txt +++ b/docs/specs/acpi_cpu_hotplug.txt @@ -90,8 +90,7 @@ write access: other values: reserved [0x6-0x7] reserved [0x8] Command data: (DWORD access) - current 'Command field' value: - 0: OSPM reads value of CPU selector + if last stored 'Command field' value: 1: stores value into OST event register 2: stores value into OST status register, triggers ACPI_DEVICE_OST QMP event from QEMU to external applications From patchwork Wed Jan 22 06:50:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 11345081 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E9A4C1398 for ; Wed, 22 Jan 2020 06:56:27 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7074C24655 for ; Wed, 22 Jan 2020 06:56:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MgT5Vh2/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7074C24655 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9wA-0004Jb-1I for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jan 2020 01:56:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36069) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9q9-0004PT-RN for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu9q8-0007tw-4a for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:13 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:29527 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iu9q8-0007tJ-0p for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579675811; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/cZSw7eZYA9nW+mh3jM5ZF40fdaxfgONBvpYjIhz74s=; b=MgT5Vh2/vdVKdOGbDdAD5FoVn9eioK7BeEozrBSGGTQFWTu3eg/ytRNI4+kDflHUNnn1rV aAxq0dy1UVqzxOfgLJgP9FaluQSyf4N9BMHgU+eeaXO75yHUi1xBQQ86v5ft7VmzUm9aNE xqfztIxGpgm4WRExqwxkFy681+S7pA8= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-177-Lh2_6RaOO3Wx6ovUnuiYLw-1; Wed, 22 Jan 2020 01:50:09 -0500 Received: by mail-wr1-f71.google.com with SMTP id y7so2614156wrm.3 for ; Tue, 21 Jan 2020 22:50:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mG4C1N5iHUE7eCiLg4lfrsmbX/tB8VxXvzlNPjmYI5U=; b=dSOfJuWx7qQ0H26qE3NBrJlEmNt42FjklYM/T4BUG0di9lGPVNrrr24k1BLHfQTYzV xsbhqKjGE0fQCp2nTmD1tKTOoLYlXNmSflAncuOCFWqCZVP3wJbUHEoRH7/LMWk8AJ36 6akm9HWcSeKLWge+JgX27cL2h7WaZsZP7g6owmEt9IoYFd8it+ruWpq+xysJSkVIlFOv Wp5FV2pLOsiYsxLbIRJzGCfi1/TT6IRoTGZDplOvoTND9Fw04YHDpMn1januUkX/hkm0 FYGUlq+cDMFwZYCDvgsmiE2eLK9vYhl9jQR0s7wfsmIiPzN7H9yuhDKXbuAbRG6SOyJR iZ1A== X-Gm-Message-State: APjAAAVuycPiUILXWZQC3gihB/HL7qaESpLsXDHK3uF27ObeJugFwSIh Kb0PoTynV76gjzWNghLxubcLKhbO/65sgXO14kOVitFw4ef7srPgp7VZYbbk/kUrAhRnnWADOXr bAtBSIumYngN5xlo= X-Received: by 2002:a1c:8086:: with SMTP id b128mr1143514wmd.80.1579675808208; Tue, 21 Jan 2020 22:50:08 -0800 (PST) X-Google-Smtp-Source: APXvYqyPtNcs+OpU2rYOHlfVnPU+mPkyzbYPd2t1DyTP8iFaYdRVyQHPdnI/DDwxOtGvqtNCdJ2OIw== X-Received: by 2002:a1c:8086:: with SMTP id b128mr1143501wmd.80.1579675808010; Tue, 21 Jan 2020 22:50:08 -0800 (PST) Received: from redhat.com (bzq-79-176-0-156.red.bezeqint.net. [79.176.0.156]) by smtp.gmail.com with ESMTPSA id t1sm2691642wma.43.2020.01.21.22.50.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 22:50:07 -0800 (PST) Date: Wed, 22 Jan 2020 01:50:05 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 06/17] acpi: cpuhp: introduce 'Command data 2' field Message-ID: <20200122064907.512501-7-mst@redhat.com> References: <20200122064907.512501-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200122064907.512501-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: Lh2_6RaOO3Wx6ovUnuiYLw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Laszlo Ersek , Igor Mammedov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov No functional change in practice, patch only aims to properly document (in spec and code) intended usage of the reserved space. The new field is to be used for 2 purposes: - detection of modern CPU hotplug interface using CPHP_GET_NEXT_CPU_WITH_EVENT_CMD command. procedure will be described in follow up patch: "acpi: cpuhp: spec: add typical usecases" - for returning upper 32 bits of architecture specific CPU ID, for new CPHP_GET_CPU_ID_CMD command added by follow up patch: "acpi: cpuhp: add CPHP_GET_CPU_ID_CMD command" Change is backward compatible with 4.2 and older machines, as field was unconditionally reserved and always returned 0x0 if modern CPU hotplug interface was enabled. Signed-off-by: Igor Mammedov Message-Id: <1575896942-331151-8-git-send-email-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Laszlo Ersek --- docs/specs/acpi_cpu_hotplug.txt | 5 ++++- hw/acpi/cpu.c | 11 +++++++++++ hw/acpi/trace-events | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/specs/acpi_cpu_hotplug.txt b/docs/specs/acpi_cpu_hotplug.txt index 8fb9ad22e6..9879f9ef7e 100644 --- a/docs/specs/acpi_cpu_hotplug.txt +++ b/docs/specs/acpi_cpu_hotplug.txt @@ -44,7 +44,10 @@ keeps the current value. read access: offset: - [0x0-0x3] reserved + [0x0-0x3] Command data 2: (DWORD access) + if value last stored in 'Command field': + 0: reads as 0x0 + other values: reserved [0x4] CPU device status fields: (1 byte access) bits: 0: Device is enabled and may be used by guest diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index 87f30a31d7..d475c06953 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -12,6 +12,7 @@ #define ACPI_CPU_FLAGS_OFFSET_RW 4 #define ACPI_CPU_CMD_OFFSET_WR 5 #define ACPI_CPU_CMD_DATA_OFFSET_RW 8 +#define ACPI_CPU_CMD_DATA2_OFFSET_R 0 enum { CPHP_GET_NEXT_CPU_WITH_EVENT_CMD = 0, @@ -79,6 +80,16 @@ static uint64_t cpu_hotplug_rd(void *opaque, hwaddr addr, unsigned size) } trace_cpuhp_acpi_read_cmd_data(cpu_st->selector, val); break; + case ACPI_CPU_CMD_DATA2_OFFSET_R: + switch (cpu_st->command) { + case CPHP_GET_NEXT_CPU_WITH_EVENT_CMD: + val = 0; + break; + default: + break; + } + trace_cpuhp_acpi_read_cmd_data2(cpu_st->selector, val); + break; default: break; } diff --git a/hw/acpi/trace-events b/hw/acpi/trace-events index 96b8273297..afbc77de1c 100644 --- a/hw/acpi/trace-events +++ b/hw/acpi/trace-events @@ -23,6 +23,7 @@ cpuhp_acpi_read_flags(uint32_t idx, uint8_t flags) "idx[0x%"PRIx32"] flags: 0x%" cpuhp_acpi_write_idx(uint32_t idx) "set active cpu idx: 0x%"PRIx32 cpuhp_acpi_write_cmd(uint32_t idx, uint8_t cmd) "idx[0x%"PRIx32"] cmd: 0x%"PRIx8 cpuhp_acpi_read_cmd_data(uint32_t idx, uint32_t data) "idx[0x%"PRIx32"] data: 0x%"PRIx32 +cpuhp_acpi_read_cmd_data2(uint32_t idx, uint32_t data) "idx[0x%"PRIx32"] data: 0x%"PRIx32 cpuhp_acpi_cpu_has_events(uint32_t idx, bool ins, bool rm) "idx[0x%"PRIx32"] inserting: %d, removing: %d" cpuhp_acpi_clear_inserting_evt(uint32_t idx) "idx[0x%"PRIx32"]" cpuhp_acpi_clear_remove_evt(uint32_t idx) "idx[0x%"PRIx32"]" From patchwork Wed Jan 22 06:50:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 11345087 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5DD3C6C1 for ; Wed, 22 Jan 2020 06:58:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 33BB72465B for ; Wed, 22 Jan 2020 06:58:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fEGwhaLc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 33BB72465B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9yT-0007mS-M6 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jan 2020 01:58:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36083) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9qC-0004SW-Fn for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu9qA-0007wE-RK for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:16 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:36338 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iu9qA-0007w5-Nh for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579675814; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e6oF8ptLJSLl44PBoGi3WUQj8MqGR3g9tIutmWvq7mo=; b=fEGwhaLctWEuDKn4B1M24xtJ91kk4qHVqLSV2p4s+iL8i/kwdX5ic49qIxiXCzk/thphiK gKtvOeBqmGuJDmspO1xCD7p9/8sRTMrPiIhR9FyH6YZS8RzazfHfV3A2/6FqxcCBsCY8SO PgYs+mQUzkDoLzXZn09ueQ4zawrDOLY= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-279-XDHyGJZmOjqWbvS5_SzhTw-1; Wed, 22 Jan 2020 01:50:12 -0500 Received: by mail-wr1-f69.google.com with SMTP id f15so2631492wrr.2 for ; Tue, 21 Jan 2020 22:50:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=e+M60MZmw7NUe0xGRZqvTtNyN03f8rI9bLRMhM9s7VE=; b=jAJlV8n+7PmAIJH2ydyMdkgW6VhXYLAck6+OZAMKCJVathqzS1V2VNaWP6cuu25vsp 2KsvhGfRoaw39ThmK8Ama66MJsHiWiAMRMkt8fukM7c2GRmFlq9uGM0QlsJvQVZDjcA5 AqaO3f7d2HnwWBrKvdrhQAdOpzot6HRz00Jj6uL3CLo/F3FWPV2QzDObzE6SPNrK+nj6 BoLTYx/F30MmTpl+sP9eILaYXLqmUIIP3PO3du8uUsO742IYiymOVBgskelJYeuDeqcc C8u+rhZp1RFI50FTRJPdg3ZomTeIvIfjHNSWyardqf6WaQSea2IIUEbLfi9Q7dZZzSaw rVPA== X-Gm-Message-State: APjAAAXUSJ8NA72dXd5FlA1QexigOiGMjVOQ2pPppBOI3xAKGSFnprT9 bA1aVDJlRhAvO9lHHakq1Bz0JVLCCS1mXyus5Fr+vJtytcC36MOHORN8bCzBAYnhhRbcVYWgftB 4Q87QZFs4WUB9uqA= X-Received: by 2002:adf:ffc7:: with SMTP id x7mr9130024wrs.159.1579675811112; Tue, 21 Jan 2020 22:50:11 -0800 (PST) X-Google-Smtp-Source: APXvYqw7XJDjBCLWWRAeQ+KLFtOrkhyXUzjbx+UZ663E8gZRNpkp8HPVJjw/fFhmI/1855IPPbQAuA== X-Received: by 2002:adf:ffc7:: with SMTP id x7mr9129994wrs.159.1579675810844; Tue, 21 Jan 2020 22:50:10 -0800 (PST) Received: from redhat.com (bzq-79-176-0-156.red.bezeqint.net. [79.176.0.156]) by smtp.gmail.com with ESMTPSA id f1sm2456183wmc.45.2020.01.21.22.50.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 22:50:10 -0800 (PST) Date: Wed, 22 Jan 2020 01:50:08 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 07/17] acpi: cpuhp: spec: add typical usecases Message-ID: <20200122064907.512501-8-mst@redhat.com> References: <20200122064907.512501-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200122064907.512501-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: XDHyGJZmOjqWbvS5_SzhTw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Laszlo Ersek , Igor Mammedov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov Document work-flows for * enabling/detecting modern CPU hotplug interface * finding a CPU with pending 'insert/remove' event * enumerating present and possible CPUs Signed-off-by: Igor Mammedov Message-Id: <1575896942-331151-9-git-send-email-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Laszlo Ersek --- docs/specs/acpi_cpu_hotplug.txt | 51 +++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/docs/specs/acpi_cpu_hotplug.txt b/docs/specs/acpi_cpu_hotplug.txt index 9879f9ef7e..cb99cf3c8e 100644 --- a/docs/specs/acpi_cpu_hotplug.txt +++ b/docs/specs/acpi_cpu_hotplug.txt @@ -15,14 +15,14 @@ CPU present bitmap for: PIIX-PM (IO port 0xaf00-0xaf1f, 1-byte access) One bit per CPU. Bit position reflects corresponding CPU APIC ID. Read-only. The first DWORD in bitmap is used in write mode to switch from legacy - to new CPU hotplug interface, write 0 into it to do switch. + to modern CPU hotplug interface, write 0 into it to do switch. --------------------------------------------------------------- QEMU sets corresponding CPU bit on hot-add event and issues SCI with GPE.2 event set. CPU present map is read by ACPI BIOS GPE.2 handler to notify OS about CPU hot-add events. CPU hot-remove isn't supported. ===================================== -ACPI CPU hotplug interface registers: +Modern ACPI CPU hotplug interface registers: ------------------------------------- Register block base address: ICH9-LPC IO port 0x0cd8 @@ -67,6 +67,7 @@ write access: [0x0-0x3] CPU selector: (DWORD access) selects active CPU device. All following accesses to other registers will read/store data from/to selected CPU. + Valid values: [0 .. max_cpus) [0x4] CPU device control fields: (1 byte access) bits: 0: reserved, OSPM must clear it before writing to register. @@ -98,4 +99,48 @@ write access: 2: stores value into OST status register, triggers ACPI_DEVICE_OST QMP event from QEMU to external applications with current values of OST event and status registers. - other values: reserved + other values: reserved + +Typical usecases: + - (x86) Detecting and enabling modern CPU hotplug interface. + QEMU starts with legacy CPU hotplug interface enabled. Detecting and + switching to modern interface is based on the 2 legacy CPU hotplug features: + 1. Writes into CPU bitmap are ignored. + 2. CPU bitmap always has bit#0 set, corresponding to boot CPU. + + Use following steps to detect and enable modern CPU hotplug interface: + 1. Store 0x0 to the 'CPU selector' register, + attempting to switch to modern mode + 2. Store 0x0 to the 'CPU selector' register, + to ensure valid selector value + 3. Store 0x0 to the 'Command field' register, + 4. Read the 'Command data 2' register. + If read value is 0x0, the modern interface is enabled. + Otherwise legacy or no CPU hotplug interface available + + - Get a cpu with pending event + 1. Store 0x0 to the 'CPU selector' register. + 2. Store 0x0 to the 'Command field' register. + 3. Read the 'CPU device status fields' register. + 4. If both bit#1 and bit#2 are clear in the value read, there is no CPU + with a pending event and selected CPU remains unchanged. + 5. Otherwise, read the 'Command data' register. The value read is the + selector of the CPU with the pending event (which is already + selected). + + - Enumerate CPUs present/non present CPUs + 01. Set the present CPU count to 0. + 02. Set the iterator to 0. + 03. Store 0x0 to the 'CPU selector' register, to ensure that it's in + a valid state and that access to other registers won't be ignored. + 04. Store 0x0 to the 'Command field' register to make 'Command data' + register return 'CPU selector' value of selected CPU + 05. Read the 'CPU device status fields' register. + 06. If bit#0 is set, increment the present CPU count. + 07. Increment the iterator. + 08. Store the iterator to the 'CPU selector' register. + 09. Read the 'Command data' register. + 10. If the value read is not zero, goto 05. + 11. Otherwise store 0x0 to the 'CPU selector' register, to put it + into a valid state and exit. + The iterator at this point equals "max_cpus". From patchwork Wed Jan 22 06:50:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 11345077 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1500B6C1 for ; Wed, 22 Jan 2020 06:54:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DF12324655 for ; Wed, 22 Jan 2020 06:54:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CAJJ+Hjm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF12324655 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9tt-000183-Hz for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jan 2020 01:54:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36103) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9qF-0004WQ-Hm for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu9qE-0007yC-58 for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:19 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:33753 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iu9qD-0007xu-Vg for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579675817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lSs10h7+g5GHkd748u1YKdPjMw3sPPNZXswgwHDuFfc=; b=CAJJ+HjmtCcz/x5Dh7DlvmrcHT5xL6LtrrN5DMs+lkywLJ+wReeskqmfLXwPLrP5vgKYVQ f1XCeFUhtA/X0PjYrkvzsbrjulAIFhW236+1W9Osqw1YmFETucxG+9z3isOuMKnkFf889S Rkr9wFS3gs6UNLCR0Xz6hvF8wGejMbc= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-95-_7qJTYvVMXuLpGYHNb_1MQ-1; Wed, 22 Jan 2020 01:50:15 -0500 Received: by mail-wr1-f71.google.com with SMTP id c17so2593750wrp.10 for ; Tue, 21 Jan 2020 22:50:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bshZ29A7PK62drys54Y2NwFiWKvTA5OkiFM7lPNvHYk=; b=naJEXgm7825di9cQuu3C2a7XjO10xks6k1G87J0mSo30tMlBO3udKA8rHqNo+jGatW AHB60YpY24Oth88XwOiYoVJtehUeKXBx4IA39RvfKEqBgkvMo85P9kjidq1xxdPA5Ed2 pA/2seleoiFb0PuRHk6OP0RePlgA3csmfaMHetNK1DAjUhanbIEYLiR8gSaxin/cPVf/ pG0HT6YhOvyKN+m3tNzulYC7E8Cl2rhdBgYfU5SKFTONwaGKSyTmLNB3oJR0Hw9WKJnL blw2CmvGB4Rk5s96f1ed3dzhoRSRHdELIppwSigTRbsUZcOSWZ9UsUiYEDw2VT3timeQ 7a6g== X-Gm-Message-State: APjAAAXxY5YDQLvfvRmdyKik/wb5SkUZAnCQ/lyZ/cIqKa226K3yD9LI Lk46aztFQjnxLkOFUqgRdKX+Hf02qoFslaUzXeGjpClJLiYZ+DbG9Cg+NTT1KJAXsX+LUAjMzeV 0WH9rIVCGAOmuzNc= X-Received: by 2002:a05:600c:2c08:: with SMTP id q8mr1191565wmg.45.1579675813998; Tue, 21 Jan 2020 22:50:13 -0800 (PST) X-Google-Smtp-Source: APXvYqxPWKcokBZRNLx3gYOad0TILV3PJbsCjBCNiF7W1ZNDIJ+8+nDlLRA9JoOIEK3yv0oksQsCAg== X-Received: by 2002:a05:600c:2c08:: with SMTP id q8mr1191549wmg.45.1579675813801; Tue, 21 Jan 2020 22:50:13 -0800 (PST) Received: from redhat.com (bzq-79-176-0-156.red.bezeqint.net. [79.176.0.156]) by smtp.gmail.com with ESMTPSA id w8sm2855363wmm.0.2020.01.21.22.50.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 22:50:13 -0800 (PST) Date: Wed, 22 Jan 2020 01:50:11 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 08/17] acpi: cpuhp: add CPHP_GET_CPU_ID_CMD command Message-ID: <20200122064907.512501-9-mst@redhat.com> References: <20200122064907.512501-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200122064907.512501-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: _7qJTYvVMXuLpGYHNb_1MQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Laszlo Ersek , Igor Mammedov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov Firmware can enumerate present at boot APs by broadcasting wakeup IPI, so that woken up secondary CPUs could register them-selves. However in CPU hotplug case, it would need to know architecture specific CPU IDs for possible and hotplugged CPUs so it could prepare environment for and wake hotplugged AP. Reuse and extend existing CPU hotplug interface to return architecture specific ID for currently selected CPU in 2 registers: - lower 32 bits in ACPI_CPU_CMD_DATA_OFFSET_RW - upper 32 bits in ACPI_CPU_CMD_DATA2_OFFSET_R On x86, firmware will use CPHP_GET_CPU_ID_CMD for fetching the APIC ID when handling hotplug SMI. Later, CPHP_GET_CPU_ID_CMD will be used on ARM to retrieve MPIDR, which serves the similar to APIC ID purpose. Signed-off-by: Igor Mammedov Message-Id: <1575896942-331151-10-git-send-email-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Laszlo Ersek --- docs/specs/acpi_cpu_hotplug.txt | 3 +++ hw/acpi/cpu.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/docs/specs/acpi_cpu_hotplug.txt b/docs/specs/acpi_cpu_hotplug.txt index cb99cf3c8e..a8ce5e7402 100644 --- a/docs/specs/acpi_cpu_hotplug.txt +++ b/docs/specs/acpi_cpu_hotplug.txt @@ -47,6 +47,7 @@ read access: [0x0-0x3] Command data 2: (DWORD access) if value last stored in 'Command field': 0: reads as 0x0 + 3: upper 32 bits of architecture specific CPU ID value other values: reserved [0x4] CPU device status fields: (1 byte access) bits: @@ -61,6 +62,8 @@ read access: [0x8] Command data: (DWORD access) contains 0 unless value last stored in 'Command field' is one of: 0: contains 'CPU selector' value of a CPU with pending event[s] + 3: lower 32 bits of architecture specific CPU ID value + (in x86 case: APIC ID) write access: offset: diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index d475c06953..e2c957ce00 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -18,6 +18,7 @@ enum { CPHP_GET_NEXT_CPU_WITH_EVENT_CMD = 0, CPHP_OST_EVENT_CMD = 1, CPHP_OST_STATUS_CMD = 2, + CPHP_GET_CPU_ID_CMD = 3, CPHP_CMD_MAX }; @@ -75,6 +76,9 @@ static uint64_t cpu_hotplug_rd(void *opaque, hwaddr addr, unsigned size) case CPHP_GET_NEXT_CPU_WITH_EVENT_CMD: val = cpu_st->selector; break; + case CPHP_GET_CPU_ID_CMD: + val = cdev->arch_id & 0xFFFFFFFF; + break; default: break; } @@ -85,6 +89,9 @@ static uint64_t cpu_hotplug_rd(void *opaque, hwaddr addr, unsigned size) case CPHP_GET_NEXT_CPU_WITH_EVENT_CMD: val = 0; break; + case CPHP_GET_CPU_ID_CMD: + val = cdev->arch_id >> 32; + break; default: break; } From patchwork Wed Jan 22 06:50:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 11345075 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 07A9D6C1 for ; Wed, 22 Jan 2020 06:54:01 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D22D924656 for ; Wed, 22 Jan 2020 06:54:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hiswUwMw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D22D924656 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37599 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9tn-0000yi-Fi for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jan 2020 01:53:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36130) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9qH-0004Z1-IA for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu9qG-0007zM-DF for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:21 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:58141) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iu9qG-0007z1-7P for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579675819; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eTnESgkc4Q1IE7eK3yhiRdRiKjKhsh/o/b9VSLnbvfo=; b=hiswUwMw68AN1N1j+9iSbSgxV19ksggwCSGghn3CcOtPGzbegVCcWwr6YxMQ2zKfYNJSqI T647Y0XbVBJvwsDDhl1/pv2dBvxpjb112AFxzd1i5nsgFNI5lM7nrYXy0gkg3KK8Qm7xHC l0vtWmm5c8+cFNFfV+wcgMBBOLy97ZE= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-13-FBqd-OhINJm1EoHkMhSgYw-1; Wed, 22 Jan 2020 01:50:18 -0500 Received: by mail-wr1-f72.google.com with SMTP id f10so2615867wro.14 for ; Tue, 21 Jan 2020 22:50:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=eAd3+nCoRQPzLOmjcY8CULrwvjv4VOu8uY/RSRtK8kQ=; b=L4gSOo7H6IS5IBXVX2Qso8GLYVuDPO00/o9nRx5Ao4BKRLJSFpAeV5zkwjpWNwmTGE sgEjCAiBupA0WQE3d/Kj1WGyZ4WIFaEGYINmccLlifxzTK9+zchl1DRd5XdZGDVNtTqx YSg999dES7pjRy+e5us0LvZLeWmmTpbED+ASbl53VJ/1jKzTYcHD4fRw/dS6vbFBSyn2 jSuwDthTNGzdzsYExt2dR2S6r0bWdvYljDWtWDmv10C1l0QMmU5Trf6d0O8rLHjJCunW ST3e1fp/3L2ZLj3K0WSJdLnmiIqhK3/qkpFU2uhRHoXGCqt027cYqcS/CwMYvA3DCMRn TiMA== X-Gm-Message-State: APjAAAWvEXXryXnaDwbeBJN+BymHjBXR8bFa2uDEQRrvtZhAfe0Qt6cv evw6QnzCpBlvuNLfFNwNIykW3aWHyCtlWjKwP8O8g/KyC0MBdJsAcVAdypnIXjPsBirRaEExmmE kYqZiWQMdqP1xjGs= X-Received: by 2002:a1c:5401:: with SMTP id i1mr1123841wmb.99.1579675816929; Tue, 21 Jan 2020 22:50:16 -0800 (PST) X-Google-Smtp-Source: APXvYqwPpNTZDpcmcF3BWq96vfyY7ZlgRBlaWVLC6h1CP8jwUBjCsqKS5d70mZxmBwomw/7qxB1sNw== X-Received: by 2002:a1c:5401:: with SMTP id i1mr1123818wmb.99.1579675816715; Tue, 21 Jan 2020 22:50:16 -0800 (PST) Received: from redhat.com (bzq-79-176-0-156.red.bezeqint.net. [79.176.0.156]) by smtp.gmail.com with ESMTPSA id m10sm56751619wrx.19.2020.01.21.22.50.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 22:50:16 -0800 (PST) Date: Wed, 22 Jan 2020 01:50:14 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 09/17] bios-tables-test: document expected file update Message-ID: <20200122064907.512501-10-mst@redhat.com> References: <20200122064907.512501-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200122064907.512501-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: FBqd-OhINJm1EoHkMhSgYw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Paolo Bonzini , Igor Mammedov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Document the flow for the case where contributor updates the expected files. Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index f1ac2d7e96..3ab4872bd7 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -16,7 +16,10 @@ * 1. add empty files for new tables, if any, under tests/data/acpi * 2. list any changed files in tests/bios-tables-test-allowed-diff.h * 3. commit the above *before* making changes that affect the tables - * Maintainer: + * + * Contributor or ACPI Maintainer (steps 4-7 need to be redone to resolve conflicts + * in binary commit created in step 6): + * * After 1-3 above tests will pass but ignore differences with the expected files. * You will also notice that tests/bios-tables-test-allowed-diff.h lists * a bunch of files. This is your hint that you need to do the below: @@ -28,13 +31,23 @@ * output. If not - disassemble them yourself in any way you like. * Look at the differences - make sure they make sense and match what the * changes you are merging are supposed to do. + * Save the changes, preferably in form of ASL diff for the commit log in + * step 6. * * 5. From build directory, run: * $(SRC_PATH)/tests/data/acpi/rebuild-expected-aml.sh - * 6. Now commit any changes. - * 7. Before doing a pull request, make sure tests/bios-tables-test-allowed-diff.h - * is empty - this will ensure following changes to ACPI tables will - * be noticed. + * 6. Now commit any changes to the expected binary, include diff from step 4 + * in commit log. + * 7. Before sending patches to the list (Contributor) + * or before doing a pull request (Maintainer), make sure + * tests/bios-tables-test-allowed-diff.h is empty - this will ensure + * following changes to ACPI tables will be noticed. + * + * The resulting patchset/pull request then looks like this: + * - patch 1: list changed files in tests/bios-tables-test-allowed-diff.h. + * - patches 2 - n: real changes, may contain multiple patches. + * - patch n + 1: update golden master binaries and empty + * tests/bios-tables-test-allowed-diff.h */ #include "qemu/osdep.h" From patchwork Wed Jan 22 06:50:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 11345083 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7DF4717EF for ; Wed, 22 Jan 2020 06:56:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 52A1D24655 for ; Wed, 22 Jan 2020 06:56:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fIOiOLPo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52A1D24655 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9wQ-0004jG-35 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jan 2020 01:56:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36142) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9qK-0004d8-U6 for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu9qJ-00082W-N0 for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:24 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:34593 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iu9qJ-00082G-JG for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579675823; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7X8PjfcFHzdyIHec4OG6du8gOrCYueQPk/uwOaIht1o=; b=fIOiOLPoOkR2bK5Xwu4S25bkRG6SBf3L5gXtJlXg5KbE66DakSrLUa2Ljo3vYuO7SxySd3 12T8wXZOJkg9V/p4UB+FT9p5mVSpGag8RzRil8Xyxd8NRtSapxpjgTkv+VA/8x6lMb/sno 4FJZD2Z65mtpIR8IR9L8TqjFlAnzvF0= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-191-oG6GzJUHM76cUoTRrOO8Nw-1; Wed, 22 Jan 2020 01:50:21 -0500 Received: by mail-wm1-f70.google.com with SMTP id q206so1663941wme.9 for ; Tue, 21 Jan 2020 22:50:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=dKz9Yp7TsPHys5pVT0H9YPlrICr7T8Twac2SXPW2Rdw=; b=l1cyxRcus/Tc/4oB7hUo6SfshT2hRZ9ADgdY8sfXnhu9lMaSZzaXqYHpPeeZiYw2A3 MiSkRPBbZ5yYZ9SfCmoUFv3exBwaRiAq2FYFEUd9O6Lcn5Dmsi5ckvnimdvR9z1f2eDt gFTIx3tBB1UZ3L50o8+TYn1iocWbrLsPkL+4o/IGxyq9Bxv/47JnZXV1yZqSKFidlZIj GErn7BVAmYKSD7Cp2nGqxXDX4XirW6gelTycAdKHYGuV1Lahi2EkhdgWq4pnwRnmCf49 NcFg6VJLWvVaQk+9OuFe7CnBce66DBnElTlODhXDY9wHqrgFhVPNEUwz68y34iTTGjGC n8kw== X-Gm-Message-State: APjAAAVZx2KE4dQ+4pS+d+uBp79qapoG9BDgDsRHTLEmujuJbUjfI0ZI ra+h0s0/lwTMKQAV9fSX1wACVjAghn9ST/Z1H+MgaQXCHkFUI3BDtw/LFJlH8usGymnL/b8D4cp R7aDlZlqJ3BgO/1g= X-Received: by 2002:adf:d846:: with SMTP id k6mr8781972wrl.337.1579675819757; Tue, 21 Jan 2020 22:50:19 -0800 (PST) X-Google-Smtp-Source: APXvYqxpOJO5NWpA77F3tU2elED9HWci00URZEaX8NRsjlDkWTwSs1NUNGRjmuytMjBPdoox4n4m3A== X-Received: by 2002:adf:d846:: with SMTP id k6mr8781955wrl.337.1579675819545; Tue, 21 Jan 2020 22:50:19 -0800 (PST) Received: from redhat.com (bzq-79-176-0-156.red.bezeqint.net. [79.176.0.156]) by smtp.gmail.com with ESMTPSA id i5sm2596058wml.31.2020.01.21.22.50.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 22:50:19 -0800 (PST) Date: Wed, 22 Jan 2020 01:50:17 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 10/17] virtio-9p-device: fix memleak in virtio_9p_device_unrealize Message-ID: <20200122064907.512501-11-mst@redhat.com> References: <20200122064907.512501-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200122064907.512501-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: oG6GzJUHM76cUoTRrOO8Nw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Christian Schoenebeck , Pan Nengyuan , Greg Kurz , Euler Robot Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Pan Nengyuan v->vq forgot to cleanup in virtio_9p_device_unrealize, the memory leak stack is as follow: Direct leak of 14336 byte(s) in 2 object(s) allocated from: #0 0x7f819ae43970 (/lib64/libasan.so.5+0xef970) ??:? #1 0x7f819872f49d (/lib64/libglib-2.0.so.0+0x5249d) ??:? #2 0x55a3a58da624 (./x86_64-softmmu/qemu-system-x86_64+0x2c14624) /mnt/sdb/qemu/hw/virtio/virtio.c:2327 #3 0x55a3a571bac7 (./x86_64-softmmu/qemu-system-x86_64+0x2a55ac7) /mnt/sdb/qemu/hw/9pfs/virtio-9p-device.c:209 #4 0x55a3a58e7bc6 (./x86_64-softmmu/qemu-system-x86_64+0x2c21bc6) /mnt/sdb/qemu/hw/virtio/virtio.c:3504 #5 0x55a3a5ebfb37 (./x86_64-softmmu/qemu-system-x86_64+0x31f9b37) /mnt/sdb/qemu/hw/core/qdev.c:876 Reported-by: Euler Robot Signed-off-by: Pan Nengyuan Message-Id: <20200117060927.51996-2-pannengyuan@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Christian Schoenebeck Acked-by: Greg Kurz --- hw/9pfs/virtio-9p-device.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index 991e175c82..ba35892940 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -218,6 +218,7 @@ static void virtio_9p_device_unrealize(DeviceState *dev, Error **errp) V9fsVirtioState *v = VIRTIO_9P(dev); V9fsState *s = &v->state; + virtio_del_queue(vdev, 0); virtio_cleanup(vdev); v9fs_device_unrealize_common(s, errp); } From patchwork Wed Jan 22 06:50:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 11345091 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B6BA692A for ; Wed, 22 Jan 2020 06:59:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8D0222465B for ; Wed, 22 Jan 2020 06:59:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dYf8RSbD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D0222465B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9yn-0008JO-C7 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jan 2020 01:59:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36166) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9qQ-0004hf-5N for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu9qP-00085F-0M for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:30 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:28135 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iu9qO-00084R-Q8 for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579675827; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WBcIJ+XtEg+ynI5J149ubW51ZuYdwReRoLvMT6MynBM=; b=dYf8RSbDOy632XLLONucymBeaYGfti5k3ZbXSrhcbLgIEQjcaLyOG4mLtb/YI1/54D7ALO u48zdnAjrG8L1nxwK/hyGPvjRizTrGyUAjvzmHRrrwP5+18geoEda22SZWK4rkCh7Hqt3B 69PkwkmNyPDAhEFE1vtX67Aya0VDzAE= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-245-NrMUa8CyOhKLtK0YiKxmIg-1; Wed, 22 Jan 2020 01:50:23 -0500 Received: by mail-wm1-f71.google.com with SMTP id 18so1657700wmp.0 for ; Tue, 21 Jan 2020 22:50:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=crW7LUnM5y+vbTajSaV+13MSOoh5cZCcUuqLsKZn8gg=; b=Im5Hk4eMduQNqK63iPH8wVMfMPLyq0YxBKe/ppJSDMnCMV+4gMjsg8igevN41wbXbd usttl8C1THq5EDOdqfxk47q66SEf88JY3qj0ADcn0A6BA8fnnjpDdMCgbWbJU84j6AnF WAxMuBQbTqGLCZTEUl7ESmZUp83o+mo2d/qUoTbSgeP7ijzkMu39XEpV/xPbyMEN7chL 8GcWPV9ye2w6DoBSTW8TtCx0hPMDOS8nM0E93Mzc7jIzu3E9Ft/hJHnGy7gq1f019L19 nEWqmEy891lti3k/qiOlV4Kmijn0DbLXGPOg5iIC8WyizPYXbhXdSCBungzS2JiAKaXe e3vg== X-Gm-Message-State: APjAAAWvs4g4UgL7mGqkBTN/MHVnjm/UgJ5AcHjfoQt94LIK9rsiOT/6 08d5WmScBK7smMXDI+f18GnTy6fu5+fObUrfemjPe/3qUC3swi2PG6dRiB8OQxxAouSdfauQZ06 XR+SjzzZfEGWCYCE= X-Received: by 2002:a1c:1fd0:: with SMTP id f199mr1140154wmf.113.1579675822565; Tue, 21 Jan 2020 22:50:22 -0800 (PST) X-Google-Smtp-Source: APXvYqylqNhmgy8OVwow7xFMvLaWSzp3Mr254uSpCFDkAC+WWb4R1DohOOOHf2Z8VW1oIa6k613c1A== X-Received: by 2002:a1c:1fd0:: with SMTP id f199mr1140135wmf.113.1579675822358; Tue, 21 Jan 2020 22:50:22 -0800 (PST) Received: from redhat.com (bzq-79-176-0-156.red.bezeqint.net. [79.176.0.156]) by smtp.gmail.com with ESMTPSA id g2sm55877810wrw.76.2020.01.21.22.50.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 22:50:21 -0800 (PST) Date: Wed, 22 Jan 2020 01:50:20 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 11/17] virtio-9p-device: convert to new virtio_delete_queue Message-ID: <20200122064907.512501-12-mst@redhat.com> References: <20200122064907.512501-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200122064907.512501-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: NrMUa8CyOhKLtK0YiKxmIg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Christian Schoenebeck , Pan Nengyuan , Greg Kurz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Pan Nengyuan Use virtio_delete_queue to make it more clear. Signed-off-by: Pan Nengyuan Message-Id: <20200117060927.51996-3-pannengyuan@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Christian Schoenebeck --- hw/9pfs/virtio-9p-device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index ba35892940..1d1c50409c 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -218,7 +218,7 @@ static void virtio_9p_device_unrealize(DeviceState *dev, Error **errp) V9fsVirtioState *v = VIRTIO_9P(dev); V9fsState *s = &v->state; - virtio_del_queue(vdev, 0); + virtio_delete_queue(v->vq); virtio_cleanup(vdev); v9fs_device_unrealize_common(s, errp); } From patchwork Wed Jan 22 06:50:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 11345085 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 927301398 for ; Wed, 22 Jan 2020 06:56:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 68FCF24655 for ; Wed, 22 Jan 2020 06:56:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="a00YQy0s" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68FCF24655 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9wS-0004md-Rv for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jan 2020 01:56:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36169) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9qQ-0004ho-8y for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu9qP-00085N-1Y for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:30 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:46800 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iu9qO-00084w-UX for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579675828; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EE2u/AAZTtiTF3BR1usKNAN0L1IlKKsiavRWKotl39g=; b=a00YQy0sPe87tPByKxbWg6Qz4zUZ3ER7XitwaHt2nkfV9S9oQdBaaTCQD6q7XxMOXC7Rgg 7G69n91wCvcX1PJer7auGcaQlMKsFmEyNfQeOrfGfRUeCYOaipCveevPRpgQPeHydvsao5 OwuSb8MvX5CgeAHi3Eq6sBxtJyzI96k= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-373-fDr0b_LXPkyTUz9KSph5xQ-1; Wed, 22 Jan 2020 01:50:26 -0500 Received: by mail-wm1-f71.google.com with SMTP id c4so1662786wmb.8 for ; Tue, 21 Jan 2020 22:50:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=uL+2BTDQ25Kv4JEooHriCyXb60bUBMFr6mqaTgyAVpc=; b=IoeN2pShs3Xc12Kg/zuousVSOdth7javHS1aqxXorslh+SidnJpW2MpUzpTUXJOBQn EqLF7oirCvPl7+R0EVpJZNnx6iCggF+IL3yLZ3V6YzNm/v+wzfDkG9nw/qMZUspA+gKf IfX9hCzjvsXhftp8YIz+MpLYBq1RY1tzr0OVexEAyKs998uRjAGMzB9djzOUgAH9Oo+C rBd7DSoYJmc6Q4plMKFduAxly8WkXZOlHAaPJ0lcAfV7F1sJJKqsbDEBKNxTmgZ9OSdk qO67GL3EnqT0aImiyZcNGjppUuF/mSGxZAn9p8NrCw6gzR0JegE/fuj5jAjmFuvTIj0Z JNfw== X-Gm-Message-State: APjAAAUq48b8Qks9WvU5wPb3tebHTGr66ITkIcb9hSapbzzwiODcd40y xI4uPcqm1ISP7Vnj0hp1wgKgphUOsj72fP+LMgKyn4FnunJ3VwuzUE3pCrgHgwxSfp0XqWzZAjo df5j1KxCHKeQbnEM= X-Received: by 2002:a1c:4907:: with SMTP id w7mr1224388wma.106.1579675825464; Tue, 21 Jan 2020 22:50:25 -0800 (PST) X-Google-Smtp-Source: APXvYqyAaP1PBbLOAwi5mhrMlI7pqx1xUI6cGdHIaBq8j8mNMomrMYaxBKMs4qu8Dd+HEOWOwU7raw== X-Received: by 2002:a1c:4907:: with SMTP id w7mr1224369wma.106.1579675825298; Tue, 21 Jan 2020 22:50:25 -0800 (PST) Received: from redhat.com (bzq-79-176-0-156.red.bezeqint.net. [79.176.0.156]) by smtp.gmail.com with ESMTPSA id s65sm2664747wmf.48.2020.01.21.22.50.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 22:50:24 -0800 (PST) Date: Wed, 22 Jan 2020 01:50:23 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 12/17] virtio-scsi: delete vqs in unrealize to avoid memleaks Message-ID: <20200122064907.512501-13-mst@redhat.com> References: <20200122064907.512501-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200122064907.512501-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: fDr0b_LXPkyTUz9KSph5xQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Pan Nengyuan , Stefan Hajnoczi , Euler Robot , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Pan Nengyuan This patch fix memleaks when attaching/detaching virtio-scsi device, the memory leak stack is as follow: Direct leak of 21504 byte(s) in 3 object(s) allocated from: #0 0x7f491f2f2970 (/lib64/libasan.so.5+0xef970) ??:? #1 0x7f491e94649d (/lib64/libglib-2.0.so.0+0x5249d) ??:? #2 0x564d0f3919fa (./x86_64-softmmu/qemu-system-x86_64+0x2c3e9fa) /mnt/sdb/qemu/hw/virtio/virtio.c:2333 #3 0x564d0f2eca55 (./x86_64-softmmu/qemu-system-x86_64+0x2b99a55) /mnt/sdb/qemu/hw/scsi/virtio-scsi.c:912 #4 0x564d0f2ece7b (./x86_64-softmmu/qemu-system-x86_64+0x2b99e7b) /mnt/sdb/qemu/hw/scsi/virtio-scsi.c:924 #5 0x564d0f39ee47 (./x86_64-softmmu/qemu-system-x86_64+0x2c4be47) /mnt/sdb/qemu/hw/virtio/virtio.c:3531 #6 0x564d0f980224 (./x86_64-softmmu/qemu-system-x86_64+0x322d224) /mnt/sdb/qemu/hw/core/qdev.c:865 Reported-by: Euler Robot Signed-off-by: Pan Nengyuan Message-Id: <20200117075547.60864-2-pannengyuan@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi --- hw/scsi/virtio-scsi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 4bc73a370e..858b3aaccb 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -943,7 +943,13 @@ void virtio_scsi_common_unrealize(DeviceState *dev) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev); + int i; + virtio_del_queue(vdev, 0); + virtio_del_queue(vdev, 1); + for (i = 0; i < vs->conf.num_queues; i++) { + virtio_del_queue(vdev, i + 2); + } g_free(vs->cmd_vqs); virtio_cleanup(vdev); } From patchwork Wed Jan 22 06:50:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 11345097 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CFC53924 for ; Wed, 22 Jan 2020 07:01:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A5FE02465B for ; Wed, 22 Jan 2020 07:01:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NiaITZmd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5FE02465B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuA1J-0002ya-Ei for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jan 2020 02:01:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36188) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9qT-0004mi-GT for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu9qS-00087y-HW for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:33 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:50851 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iu9qS-00087V-ED for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579675832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1MaCdSCC18sa84xXKLha22neuWnQ0FyF+hqtGDwgw+w=; b=NiaITZmdEc6liMgCHla5+v3NcjZf5bS7/SDF83yXjUNeKz9eDb2qWOsdkJcqjmhWiguO7z IkzPeEJ7iiXi2CtSoerkxh10/KBG/ffRgZykwKeM+0GWXTMnHSUVeDycyhe6z93knjRvCI qw6d6Eq0nRWSHofsqiUqDTghFmDIVKg= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-124-Wx9wPHuJPYauqPf8VLB1CA-1; Wed, 22 Jan 2020 01:50:30 -0500 Received: by mail-wm1-f71.google.com with SMTP id c4so1662816wmb.8 for ; Tue, 21 Jan 2020 22:50:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=JmSFm2DvEaju83wiB8EwbENmzUyJC9M0V+2bn9XbrpU=; b=OLMtT4WNpAOBwSqJtjRW+XYvdFPeh35i9mkf0iQ2WlkOrAWKYyfT2fF7duMLT7hT6j 1Y7ks10nLJxU9YA0xOjKjKAn9Vm/M/IygV1f1Nw67lmm0nej+SVQWSemXCpslFAO16nH X20rLb4B+fGrA2vvjO0FXhupwPg7qoHqq8oIF4p4mA8urfsVlgQQm3GCxgvhNRvWUqP1 /+iiBDAMZ2O7CvnqjEOGvhBJ1HoiSJIOo4icYXBWg8QpYDqZB6724Wcida6KqnbUTVDr YG1awJs8CHrBjLsdL3hGGutdq6ZHQUiOPLVGZqy3nQ3+wUKG9I2xMVrtwb3SOEPAiNTO TPyQ== X-Gm-Message-State: APjAAAVuE7dhFVcaZfOYFiRqKyvZFClWEpFLuqarop8vTU1orst5WW4n Wt4KMGH42dSzxb6JHy1btHHBx+toCn2jCUomYGjf950LBIJa0AyVqBLzD1JcsClM6X7jTAV0ZnX KkOs4QtPUafHHyrM= X-Received: by 2002:adf:fd07:: with SMTP id e7mr9257554wrr.21.1579675828449; Tue, 21 Jan 2020 22:50:28 -0800 (PST) X-Google-Smtp-Source: APXvYqz/HrlNqG6YM++k5ZW2aqsZjD8ga4Q+R886x/rU91Zg3OHn+KL/GNKmbOHUUoWAAeNKqTrODw== X-Received: by 2002:adf:fd07:: with SMTP id e7mr9257538wrr.21.1579675828282; Tue, 21 Jan 2020 22:50:28 -0800 (PST) Received: from redhat.com (bzq-79-176-0-156.red.bezeqint.net. [79.176.0.156]) by smtp.gmail.com with ESMTPSA id i10sm56892035wru.16.2020.01.21.22.50.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 22:50:27 -0800 (PST) Date: Wed, 22 Jan 2020 01:50:25 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 13/17] virtio-scsi: convert to new virtio_delete_queue Message-ID: <20200122064907.512501-14-mst@redhat.com> References: <20200122064907.512501-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200122064907.512501-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: Wx9wPHuJPYauqPf8VLB1CA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Pan Nengyuan , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Pan Nengyuan Use virtio_delete_queue to make it more clear. Signed-off-by: Pan Nengyuan Message-Id: <20200117075547.60864-3-pannengyuan@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi --- hw/scsi/virtio-scsi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 858b3aaccb..d3af42ef92 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -945,10 +945,10 @@ void virtio_scsi_common_unrealize(DeviceState *dev) VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev); int i; - virtio_del_queue(vdev, 0); - virtio_del_queue(vdev, 1); + virtio_delete_queue(vs->ctrl_vq); + virtio_delete_queue(vs->event_vq); for (i = 0; i < vs->conf.num_queues; i++) { - virtio_del_queue(vdev, i + 2); + virtio_delete_queue(vs->cmd_vqs[i]); } g_free(vs->cmd_vqs); virtio_cleanup(vdev); From patchwork Wed Jan 22 06:50:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 11345089 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D22BF92A for ; Wed, 22 Jan 2020 06:59:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A8BCF2465B for ; Wed, 22 Jan 2020 06:59:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Fl9nljzx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A8BCF2465B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9yg-000874-E2 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jan 2020 01:59:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36199) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9qW-0004su-V9 for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu9qV-00089z-JX for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:36 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:45816 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iu9qV-00089i-GO for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579675835; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Fvu/JejnrpbIYjtd6kH0elorwKES/+22eaULELxAawU=; b=Fl9nljzxEbWRFnP6FRxrSoTbkKO6oVwoprLfK30UpMst1WWqrR7gJzMyEHEk1Dfer1WYnD y3AnIEnGQUw78LBJD3rZ1l+aHshiOQk+mA7omeNzrwaAdm1HzgkzoEvbnKplaoYM6H7fRk sgQNRQouwWE7DbkCMcpq7t6RHu6HieQ= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-247-hAfWfcCON2eVPLMoIe12Lw-1; Wed, 22 Jan 2020 01:50:33 -0500 Received: by mail-wr1-f72.google.com with SMTP id d8so2585794wrq.12 for ; Tue, 21 Jan 2020 22:50:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Pvkfe/62fecBB0WaC+0Ls5admcVzWgltEZR0OGv8pe0=; b=U/vaKsX9m69Mjx3TbaAf4hitq18/NKQw+nvym301cZx4VGgC0pKJks3ENSPMuIMUES reWUdonb35AR9ehoEdC5N8FLxnMWW/k1j6Vq4Nxqocb6xlxcPPH8V8ppY0/qJR7TV2Nw lHj8jrEXWD86JnxaKPgkOGMosl758/DyIvT4MefCm4lL88xHUySgIPo3lU7cKTGvqAp0 Yg9Ga8FzHpL1TBHFsiGfhIb2RVgHKe/IdapDhzuLMCVYcDbXOmbhu6RyaBZ8GihbEcfZ u1bf0AKfAVFMEtPHQ5CwQU5grr+xpYUq80exoPhTiNF4OQ/FzVCzOCIpLpldOyxwn4zi /7qQ== X-Gm-Message-State: APjAAAWlYE74vyVpvF/YUmnA3wE2lrEUJ1CkA2q9tNZ4A1TYiAZUFq+x I/HzMSC4Z+FAMt+7zUhdEWeMUII8+WG5PMWkDWAnOyk0SRadgCKXt/EnvNSvRAuMKW+FeEdYDSt uNDO63lv9G49+n/k= X-Received: by 2002:adf:8541:: with SMTP id 59mr9301256wrh.307.1579675831602; Tue, 21 Jan 2020 22:50:31 -0800 (PST) X-Google-Smtp-Source: APXvYqxD7M6pNst3XdABjFe+H6o/3UTX45nqmSSyySfdRObqyd+Jgv0N87yWQplhFs6c9DODU+cpZA== X-Received: by 2002:adf:8541:: with SMTP id 59mr9301230wrh.307.1579675831342; Tue, 21 Jan 2020 22:50:31 -0800 (PST) Received: from redhat.com (bzq-79-176-0-156.red.bezeqint.net. [79.176.0.156]) by smtp.gmail.com with ESMTPSA id t190sm2521163wmt.44.2020.01.21.22.50.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 22:50:30 -0800 (PST) Date: Wed, 22 Jan 2020 01:50:29 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 14/17] vhost-vsock: delete vqs in vhost_vsock_unrealize to avoid memleaks Message-ID: <20200122064907.512501-15-mst@redhat.com> References: <20200122064907.512501-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200122064907.512501-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: hAfWfcCON2eVPLMoIe12Lw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefano Garzarella , Pan Nengyuan , Stefan Hajnoczi , Euler Robot Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Pan Nengyuan Receive/transmit/event vqs forgot to cleanup in vhost_vsock_unrealize. This patch save receive/transmit vq pointer in realize() and cleanup vqs through those vq pointers in unrealize(). The leak stack is as follow: Direct leak of 21504 byte(s) in 3 object(s) allocated from: #0 0x7f86a1356970 (/lib64/libasan.so.5+0xef970) ??:? #1 0x7f86a09aa49d (/lib64/libglib-2.0.so.0+0x5249d) ??:? #2 0x5604852f85ca (./x86_64-softmmu/qemu-system-x86_64+0x2c3e5ca) /mnt/sdb/qemu/hw/virtio/virtio.c:2333 #3 0x560485356208 (./x86_64-softmmu/qemu-system-x86_64+0x2c9c208) /mnt/sdb/qemu/hw/virtio/vhost-vsock.c:339 #4 0x560485305a17 (./x86_64-softmmu/qemu-system-x86_64+0x2c4ba17) /mnt/sdb/qemu/hw/virtio/virtio.c:3531 #5 0x5604858e6b65 (./x86_64-softmmu/qemu-system-x86_64+0x322cb65) /mnt/sdb/qemu/hw/core/qdev.c:865 #6 0x5604861e6c41 (./x86_64-softmmu/qemu-system-x86_64+0x3b2cc41) /mnt/sdb/qemu/qom/object.c:2102 Reported-by: Euler Robot Signed-off-by: Pan Nengyuan Message-Id: <20200115062535.50644-1-pannengyuan@huawei.com> Reviewed-by: Stefano Garzarella Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-vsock.h | 2 ++ hw/virtio/vhost-vsock.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/hw/virtio/vhost-vsock.h b/include/hw/virtio/vhost-vsock.h index d509d67c4a..bc5a988ee5 100644 --- a/include/hw/virtio/vhost-vsock.h +++ b/include/hw/virtio/vhost-vsock.h @@ -33,6 +33,8 @@ typedef struct { struct vhost_virtqueue vhost_vqs[2]; struct vhost_dev vhost_dev; VirtQueue *event_vq; + VirtQueue *recv_vq; + VirtQueue *trans_vq; QEMUTimer *post_load_timer; /*< public >*/ diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index f5744363a8..b6cee479bb 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -335,8 +335,10 @@ static void vhost_vsock_device_realize(DeviceState *dev, Error **errp) sizeof(struct virtio_vsock_config)); /* Receive and transmit queues belong to vhost */ - virtio_add_queue(vdev, VHOST_VSOCK_QUEUE_SIZE, vhost_vsock_handle_output); - virtio_add_queue(vdev, VHOST_VSOCK_QUEUE_SIZE, vhost_vsock_handle_output); + vsock->recv_vq = virtio_add_queue(vdev, VHOST_VSOCK_QUEUE_SIZE, + vhost_vsock_handle_output); + vsock->trans_vq = virtio_add_queue(vdev, VHOST_VSOCK_QUEUE_SIZE, + vhost_vsock_handle_output); /* The event queue belongs to QEMU */ vsock->event_vq = virtio_add_queue(vdev, VHOST_VSOCK_QUEUE_SIZE, @@ -363,6 +365,9 @@ static void vhost_vsock_device_realize(DeviceState *dev, Error **errp) err_vhost_dev: vhost_dev_cleanup(&vsock->vhost_dev); err_virtio: + virtio_delete_queue(vsock->recv_vq); + virtio_delete_queue(vsock->trans_vq); + virtio_delete_queue(vsock->event_vq); virtio_cleanup(vdev); close(vhostfd); return; @@ -379,6 +384,9 @@ static void vhost_vsock_device_unrealize(DeviceState *dev, Error **errp) vhost_vsock_set_status(vdev, 0); vhost_dev_cleanup(&vsock->vhost_dev); + virtio_delete_queue(vsock->recv_vq); + virtio_delete_queue(vsock->trans_vq); + virtio_delete_queue(vsock->event_vq); virtio_cleanup(vdev); } From patchwork Wed Jan 22 06:50:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 11345107 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A65592A for ; Wed, 22 Jan 2020 07:04:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2FE6F2465B for ; Wed, 22 Jan 2020 07:04:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Uz8CSCNt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2FE6F2465B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuA3w-0005Ug-8v for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jan 2020 02:04:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36210) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9qY-0004uq-R6 for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu9qX-0008BY-Os for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:38 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:56929 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iu9qX-0008BE-LC for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579675837; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rfFv49LFSLdXK1/7HJzZJqCabeu5CMr+Q9T61Qs2V4s=; b=Uz8CSCNtz5tnjCjyg/srLIow9GUMJ4hQ+XEmHDn6z4lL+KWbrJlk0KyvpUGyZmD6y0x+mG xw5IwZg9eHosx2VaVMKhF7gkVtnQLbufNt14PVAds9+WgbbYGzfNt6WxHfpS2PmB6OO3Wm xPN7UGgtbHuMoQI1jrYEaCVstu2Ylg4= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-65-WeUBRaM0OKmpUZ9cKInegg-1; Wed, 22 Jan 2020 01:50:35 -0500 Received: by mail-wr1-f72.google.com with SMTP id k18so2613582wrw.9 for ; Tue, 21 Jan 2020 22:50:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=EdvlCEDlyygl5LZfs8930w7NjWVUhDfxRmswNGuyQBQ=; b=naHdCSjzRTPqZhpxNzpOWDYcsfQmgpKxKBYmiwntRwwHF8Oe2o4pikUPabR15OTnpd YjCNLDmVHt7O4j/LlP0AYBtPx8F9nS8Q4SLdazgqJfbVPfjqcFZvI+OnyZQiUynULQA7 plamTmZ29Q9xUstQmTMzWvjaiJHupwifPSv2NuwpubZcb15d4d+xYr1WaRSajc9SnsCz MBjhk/CseUHmeuhzga3oj2zN+FWacNr9H/ae5IvqLQxGxx2Siuy6YnEn5Eo18DrD7urC twyZxbQeWibt6uO9F4XtHgvv0yD6gJgwdWkNz6zniS57qz6i7Mh7xM3uPRbaSBn33ITi aBFA== X-Gm-Message-State: APjAAAVRUqhT7ggnWIdFzBrxSZny6xN6V8ecCTMgZZLzK8Hk1M8Gb46D t6JGkgDSzwOrkc2NCSUa7OUlhqO6ktf0Hp3ZWeobUK25K13oUPyjdRymR+8OVmBS4RB3uHO3DUM EwWTBvKeSsiAMzlU= X-Received: by 2002:a5d:558d:: with SMTP id i13mr9227189wrv.364.1579675834355; Tue, 21 Jan 2020 22:50:34 -0800 (PST) X-Google-Smtp-Source: APXvYqx7WPklQFNZv/KRAo/tjmw3visjEB2U/g6CsYfvPiLgDG/ZnjC7EmzvQ8FBLyivLKVwzbwucQ== X-Received: by 2002:a5d:558d:: with SMTP id i13mr9227174wrv.364.1579675834166; Tue, 21 Jan 2020 22:50:34 -0800 (PST) Received: from redhat.com (bzq-79-176-0-156.red.bezeqint.net. [79.176.0.156]) by smtp.gmail.com with ESMTPSA id c4sm2560063wml.7.2020.01.21.22.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 22:50:33 -0800 (PST) Date: Wed, 22 Jan 2020 01:50:32 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 15/17] vhost: Add names to section rounded warning Message-ID: <20200122064907.512501-16-mst@redhat.com> References: <20200122064907.512501-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200122064907.512501-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: WeUBRaM0OKmpUZ9cKInegg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: "Dr. David Alan Gilbert" Add the memory region names to section rounding/alignment warnings. Signed-off-by: Dr. David Alan Gilbert Message-Id: <20200116202414.157959-2-dgilbert@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 4da0d5a6c5..774d87d98e 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -590,9 +590,10 @@ static void vhost_region_add_section(struct vhost_dev *dev, * match up in the same RAMBlock if they do. */ if (mrs_gpa < prev_gpa_start) { - error_report("%s:Section rounded to %"PRIx64 - " prior to previous %"PRIx64, - __func__, mrs_gpa, prev_gpa_start); + error_report("%s:Section '%s' rounded to %"PRIx64 + " prior to previous '%s' %"PRIx64, + __func__, section->mr->name, mrs_gpa, + prev_sec->mr->name, prev_gpa_start); /* A way to cleanly fail here would be better */ return; } From patchwork Wed Jan 22 06:50:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 11345093 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2BD76C1 for ; Wed, 22 Jan 2020 06:59:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 991052465B for ; Wed, 22 Jan 2020 06:59:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WyfbOuJb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 991052465B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9zY-0000y2-8K for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jan 2020 01:59:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36222) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9qc-00050j-DR for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu9qb-0008E7-54 for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:42 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:58523 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iu9qb-0008Dq-1c for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579675840; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sUTzXG5c0P/cfpSyLzCfAtskYDWEcm5+URpIdvpUQzQ=; b=WyfbOuJbSznrZiBbYF2T5yJYfLZ/WJ64Sf4wzpNLYdOpFzXD3EC3ST8vjJxoCH0kbJamrs TIcOCkh2J9DhmgGz4T+lEQF5LvMNRzh7IBtNXpdcttuCHZfo2pm7uZ+oY3bqSIO+oENP35 9PBlLou8EvdNXIkoM+QBs23nTz4G6xQ= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-436-Yhx5HnvWOj2EF_77E-P4pQ-1; Wed, 22 Jan 2020 01:50:38 -0500 Received: by mail-wr1-f71.google.com with SMTP id f17so2598792wrt.19 for ; Tue, 21 Jan 2020 22:50:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=miOqrXp0EkoFa9QINKw9BvmGX6vXumq1+xiaY2GCJjQ=; b=pecB/Z9W5kVDqmYEWI++MQ8AR5tjNLeD+QPmug0Z3oQham/4ydmRkweKJ1gIkVewvM OK+AZFIKn27KWMQ8HSGzvyCi8RRYfV+ZGToYgrU7ybZ+YGGrgqCm3TyEU5JEhQTVJ73S glKmTk+xAHEFGnoC4sjGK4lkKrSa0MsAE+M8mZ2lbKeNkVesaPbZjY0s+MfPrzhtMFrR xjgYjp0UH8ZToaMMiGzorXuB4l9ynbqsrthJi9+GuHmVT+79xLX41TSo5PvgXs041TKy OF+g7uAtFauchLvLqAnvqoPgnB6uLHG397ABTZO0ITT5FqxyWW/mkD2yR7uwp5fdjUw/ C2iA== X-Gm-Message-State: APjAAAVeO1APAJjHUccVYYLaVHHkpNux551HoxhKqFK8vFwC6MZ4kbIz lB/vEv4LNA+OAjR207D2GxZIWOiz3fOrMm2MJUH9Fea1zZxOpGK2hKrkixfaJAzINQc2bSiSZ+w j/+ImXCjj64vBeZs= X-Received: by 2002:a05:6000:367:: with SMTP id f7mr9225563wrf.174.1579675837038; Tue, 21 Jan 2020 22:50:37 -0800 (PST) X-Google-Smtp-Source: APXvYqyjh52+qS1ilGDb234D6YPFTtWYiQLaUxKthR5iBPmnKs70yKOCVw1eRwV23h1WXT0VQhOl2w== X-Received: by 2002:a05:6000:367:: with SMTP id f7mr9225543wrf.174.1579675836813; Tue, 21 Jan 2020 22:50:36 -0800 (PST) Received: from redhat.com (bzq-79-176-0-156.red.bezeqint.net. [79.176.0.156]) by smtp.gmail.com with ESMTPSA id d23sm2365597wra.30.2020.01.21.22.50.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 22:50:36 -0800 (PST) Date: Wed, 22 Jan 2020 01:50:34 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 16/17] vhost: Only align sections for vhost-user Message-ID: <20200122064907.512501-17-mst@redhat.com> References: <20200122064907.512501-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200122064907.512501-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: Yhx5HnvWOj2EF_77E-P4pQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "Dr. David Alan Gilbert" , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: "Dr. David Alan Gilbert" I added hugepage alignment code in c1ece84e7c9 to deal with vhost-user + postcopy which needs aligned pages when using userfault. However, on x86 the lower 2MB of address space tends to be shotgun'd with small fragments around the 512-640k range - e.g. video RAM, and with HyperV synic pages tend to sit around there - again splitting it up. The alignment code complains with a 'Section rounded to ...' error and gives up. Since vhost-user already filters out devices without an fd (see vhost-user.c vhost_user_mem_section_filter) it shouldn't be affected by those overlaps. Turn the alignment off on vhost-kernel so that it doesn't try and align, and thus won't hit the rounding issues. Signed-off-by: Dr. David Alan Gilbert Message-Id: <20200116202414.157959-3-dgilbert@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Paolo Bonzini --- hw/virtio/vhost.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 774d87d98e..25fd469179 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -547,26 +547,28 @@ static void vhost_region_add_section(struct vhost_dev *dev, uintptr_t mrs_host = (uintptr_t)memory_region_get_ram_ptr(section->mr) + section->offset_within_region; RAMBlock *mrs_rb = section->mr->ram_block; - size_t mrs_page = qemu_ram_pagesize(mrs_rb); trace_vhost_region_add_section(section->mr->name, mrs_gpa, mrs_size, mrs_host); - /* Round the section to it's page size */ - /* First align the start down to a page boundary */ - uint64_t alignage = mrs_host & (mrs_page - 1); - if (alignage) { - mrs_host -= alignage; - mrs_size += alignage; - mrs_gpa -= alignage; + if (dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER) { + /* Round the section to it's page size */ + /* First align the start down to a page boundary */ + size_t mrs_page = qemu_ram_pagesize(mrs_rb); + uint64_t alignage = mrs_host & (mrs_page - 1); + if (alignage) { + mrs_host -= alignage; + mrs_size += alignage; + mrs_gpa -= alignage; + } + /* Now align the size up to a page boundary */ + alignage = mrs_size & (mrs_page - 1); + if (alignage) { + mrs_size += mrs_page - alignage; + } + trace_vhost_region_add_section_aligned(section->mr->name, mrs_gpa, mrs_size, + mrs_host); } - /* Now align the size up to a page boundary */ - alignage = mrs_size & (mrs_page - 1); - if (alignage) { - mrs_size += mrs_page - alignage; - } - trace_vhost_region_add_section_aligned(section->mr->name, mrs_gpa, mrs_size, - mrs_host); if (dev->n_tmp_sections) { /* Since we already have at least one section, lets see if From patchwork Wed Jan 22 06:50:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 11345095 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AE4F92A for ; Wed, 22 Jan 2020 07:01:42 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F21052465B for ; Wed, 22 Jan 2020 07:01:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JFIRUMLu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F21052465B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuA1E-0002r1-G0 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jan 2020 02:01:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36246) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu9qh-00058d-Rd for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu9qg-0008HW-6W for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:47 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:32816 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iu9qg-0008HB-1j for qemu-devel@nongnu.org; Wed, 22 Jan 2020 01:50:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579675845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ggBqUw/TkyscUgLTaAI+ToeLG/4Kdqwt2Kyfz0gAqcA=; b=JFIRUMLuHgXQjNQqi2RLP+wqqAtCbPuwY3sMZvv4iPbj7SE1JWOlVMWY29Hz7JU61jxNJ2 W0Wb/AXc/dAfJNfR75EDvK/+ay0jNu1GyLn+Aergfy8rQb+Onc79LyfHZnKc3goItK1IJO tMCw5oJvBNKT/X+N/sT1t5SYdZvdttE= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-14-i5u61N1JOLGpp2LO0UPt9g-1; Wed, 22 Jan 2020 01:50:41 -0500 Received: by mail-wr1-f71.google.com with SMTP id b13so2570027wrx.22 for ; Tue, 21 Jan 2020 22:50:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=cGSuN6h1x+S1blKGljaTMghfpV/GT8UXotLBiV9qbUk=; b=fhztdxq54s1jH3IlUlcyd2yP4wFcBmmJnxujJuEzrJqmS9LFXKUcyC6ilH9Rh1DpvH hCy83pGEUM6IIYFU11gjr3X0PuIjzgVxaUV1WhZKNle5xjKE3FfaXXW3Lr2A1f49CBQl 2VFpFqCoeI7jm3OoVwHp7SHmGltFvoiJsZFE8lO3NzJ8myE8EEEdyvuZ15LqMz8Q+0+w imp2XFBr5nxjxN8n/VJDrtPKn6JPxxoxXJMDiodTd/gFBZeuVYT90yWV9LpoEGXYTo4H XKYEjhcTKHNl6AMtSQ3cy+Jfu4OX5hNrm4J+MjAjoHi3kOZosKNC1ml0ycmb0EjyNEL0 OeaA== X-Gm-Message-State: APjAAAU2dggv0z/yq85I0ltLP+Ujw1la2CmWkKSuKpE4ZDPgT8qz8gl2 6xQ57k5T+sZ2WxySlCdpBHE2eXEx6tvblC0jUterQ6cbbDlsY3/3ndnx7dIDY9l3Q4slDv2iFoh RcWAytxCoXynfHOw= X-Received: by 2002:a1c:1b15:: with SMTP id b21mr1151390wmb.17.1579675840075; Tue, 21 Jan 2020 22:50:40 -0800 (PST) X-Google-Smtp-Source: APXvYqxds0R5O4f5SzRAs4/PJ10l/GHzq4vo2bxr459ykGSQ9MyvA6HtCqK0xyB1yCYJQmo3cFpkPA== X-Received: by 2002:a1c:1b15:: with SMTP id b21mr1151363wmb.17.1579675839842; Tue, 21 Jan 2020 22:50:39 -0800 (PST) Received: from redhat.com (bzq-79-176-0-156.red.bezeqint.net. [79.176.0.156]) by smtp.gmail.com with ESMTPSA id w17sm55807017wrt.89.2020.01.21.22.50.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 22:50:39 -0800 (PST) Date: Wed, 22 Jan 2020 01:50:37 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 17/17] i386:acpi: Remove _HID from the SMBus ACPI entry Message-ID: <20200122064907.512501-18-mst@redhat.com> References: <20200122064907.512501-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200122064907.512501-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: i5u61N1JOLGpp2LO0UPt9g-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Corey Minyard , Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard Per the ACPI spec (version 6.1, section 6.1.5 _HID) it is not required on enumerated buses (like PCI in this case), _ADR is required (and is already there). And the _HID value is wrong. Linux appears to ignore the _HID entry, but Windows 10 detects it as 'Unknown Device' and there is no driver available. See https://bugs.launchpad.net/qemu/+bug/1856724 Signed-off-by: Corey Minyard Cc: Michael S. Tsirkin Cc: Igor Mammedov Reviewed-by: Igor Mammedov Message-Id: <20200120170725.24935-6-minyard@acm.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-build.c | 1 - tests/data/acpi/q35/DSDT | Bin 7879 -> 7869 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9203 -> 9193 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7896 -> 7886 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8342 -> 8332 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9532 -> 9522 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7954 -> 7944 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9238 -> 9228 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 9009 -> 8999 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7885 -> 7875 bytes 10 files changed, 1 deletion(-) diff --git a/tests/data/acpi/q35/DSDT b/tests/data/acpi/q35/DSDT index 77ea60ffed421c566138fe6341421f579129a582..1f91888d7a485850cf27f152e247a90b208003dc 100644 GIT binary patch delta 42 xcmX?ZyVsV>CDe&h`+ diff --git a/tests/data/acpi/q35/DSDT.dimmpxm b/tests/data/acpi/q35/DSDT.dimmpxm index 23fdf5e60a5069f60d6c680ac9c68c4a8a81318e..02ccdd5f38d5b2356dcca89398c41dcf2595dfff 100644 GIT binary patch delta 42 xcmdnvwaJUiCDv8151UVN}qe1Nm3L39&;u&FFx2QKET=2Ai9Y^*w@Km^J2+-Rsi7S3kU!J delta 52 zcmeCMn`Fo366_KpB+tOWxOgL1ouss?UVN}qe1Nm3L3ER3u&>&QD-BUv81%BUVN}qe1Nm3L3ER3u&