From nobody Sat Apr 27 11:19:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1579283473; cv=none; d=zohomail.com; s=zohoarc; b=mS5u5+JagskGLsD1meqDEyDkhK6MfanQIBAvFzPn7Qm2D6alOCVXPp0COcwrscurnFtWEQkAMi/HKDnYXIXH9GeC9tm9tar1AiitXurjig/z6GkdL+DzdT/6InPqAWi0moeyBROqsSp3qgaFNH0nZYaAVzFvWQUAfsMEO3wlLzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579283473; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EQ7xi/mOPeeUkvyPjHA7kR8Etv9LpWQhMN4lcbbRMLk=; b=WtOb3q6/8+6NrHampo+zlHr5WLezNa7QHEqxTDcxeg+y45ISUud1AgM+bLAAkI9TipKqMip0QbyZl5ImpBxJZtuyLiXmb/vMYhNXHe94komPgdhnYXRYZ9W1mNc2P6yBM9AK7k0T/1Nbb/h9WGeSF1k0N7O6A0FvqOF8dapbRQg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579283473037792.8669019387944; Fri, 17 Jan 2020 09:51:13 -0800 (PST) Received: from localhost ([::1]:32912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isVm3-00072C-R7 for importer@patchew.org; Fri, 17 Jan 2020 12:51:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55816) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isVi3-0002Gm-Pj for qemu-devel@nongnu.org; Fri, 17 Jan 2020 12:47:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1isVi2-0007hk-9k for qemu-devel@nongnu.org; Fri, 17 Jan 2020 12:47:03 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:58598 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1isVhw-0007YX-U9; Fri, 17 Jan 2020 12:46:57 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 9949E37FDB5A6132F07A; Sat, 18 Jan 2020 01:46:51 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Sat, 18 Jan 2020 01:46:41 +0800 From: Shameer Kolothum To: , , , Subject: [PATCH v2 1/7] exec: Fix for qemu_ram_resize() callback Date: Fri, 17 Jan 2020 17:45:16 +0000 Message-ID: <20200117174522.22044-2-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20200117174522.22044-1-shameerali.kolothum.thodi@huawei.com> References: <20200117174522.22044-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 45.249.212.32 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@linaro.org, xiaoguangrong.eric@gmail.com, mst@redhat.com, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If ACPI blob length modifications happens after the initial virt_acpi_build() call, and the changed blob length is within the PAGE size boundary, then the revised size is not seen by the firmware on Guest reboot. The is because in the virt_acpi_build_update() -> acpi_ram_update() -> qemu_ram_resize() path, qemu_ram_resize() uses used_length (ram_block size which is aligned to PAGE size) and the "resize callback" to update the size seen by firmware is not getting invoked. Hence make sure callback is called if the new size is different from original requested size. Signed-off-by: Shameer Kolothum Acked-by: Igor Mammedov --- Please find the previous discussions on this issue here, https://patchwork.kernel.org/patch/11174947/ But this one attempts a different solution to fix it by introducing req_length var to RAMBlock struct.=20 --- exec.c | 36 +++++++++++++++++++++++------------- include/exec/ram_addr.h | 5 +++-- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/exec.c b/exec.c index d4b769d0d4..9ce33992f8 100644 --- a/exec.c +++ b/exec.c @@ -2123,16 +2123,18 @@ static int memory_try_enable_merging(void *addr, si= ze_t len) * resize callback to update device state and/or add assertions to detect * misuse, if necessary. */ -int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp) +int qemu_ram_resize(RAMBlock *block, ram_addr_t size, Error **errp) { - assert(block); + ram_addr_t newsize; =20 - newsize =3D HOST_PAGE_ALIGN(newsize); + assert(block); =20 - if (block->used_length =3D=3D newsize) { + if (block->req_length =3D=3D size) { return 0; } =20 + newsize =3D HOST_PAGE_ALIGN(size); + if (!(block->flags & RAM_RESIZEABLE)) { error_setg_errno(errp, EINVAL, "Length mismatch: %s: 0x" RAM_ADDR_FMT @@ -2149,13 +2151,19 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t new= size, Error **errp) return -EINVAL; } =20 - cpu_physical_memory_clear_dirty_range(block->offset, block->used_lengt= h); - block->used_length =3D newsize; - cpu_physical_memory_set_dirty_range(block->offset, block->used_length, - DIRTY_CLIENTS_ALL); - memory_region_set_size(block->mr, newsize); + block->req_length =3D size; + + if (newsize !=3D block->used_length) { + cpu_physical_memory_clear_dirty_range(block->offset, + block->used_length); + block->used_length =3D newsize; + cpu_physical_memory_set_dirty_range(block->offset, block->used_len= gth, + DIRTY_CLIENTS_ALL); + memory_region_set_size(block->mr, newsize); + } + if (block->resized) { - block->resized(block->idstr, newsize, block->host); + block->resized(block->idstr, block->req_length, block->host); } return 0; } @@ -2412,16 +2420,18 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, = ram_addr_t max_size, MemoryRegion *mr, Error **errp) { RAMBlock *new_block; + ram_addr_t newsize; Error *local_err =3D NULL; =20 - size =3D HOST_PAGE_ALIGN(size); + newsize =3D HOST_PAGE_ALIGN(size); max_size =3D HOST_PAGE_ALIGN(max_size); new_block =3D g_malloc0(sizeof(*new_block)); new_block->mr =3D mr; new_block->resized =3D resized; - new_block->used_length =3D size; + new_block->req_length =3D size; + new_block->used_length =3D newsize; new_block->max_length =3D max_size; - assert(max_size >=3D size); + assert(max_size >=3D newsize); new_block->fd =3D -1; new_block->page_size =3D qemu_real_host_page_size; new_block->host =3D host; diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 5adebb0bc7..fd13082224 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -31,8 +31,9 @@ struct RAMBlock { uint8_t *host; uint8_t *colo_cache; /* For colo, VM's ram cache */ ram_addr_t offset; - ram_addr_t used_length; - ram_addr_t max_length; + ram_addr_t req_length; /* Original requested size, used if RAM_RESIZEA= BLE */ + ram_addr_t used_length; /* aligned to qemu_host_page_size */ + ram_addr_t max_length; /* aligned to qemu_host_page_size */ void (*resized)(const char*, uint64_t length, void *host); uint32_t flags; /* Protected by iothread lock. */ --=20 2.17.1 From nobody Sat Apr 27 11:19:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1579283330; cv=none; d=zohomail.com; s=zohoarc; b=N3RUCGQWtufiUEknzzsRzw9mz48CmDKYDE78MllAszwQo6AbeRNWnMXmQQCwHSDa1OXmJpU8EuqSYNexlq9Qxm1YAO4Lg15VnYHpBh+ibBbMoDgPORCNBYKcaBup+qtXJqGesM2M5GW2tjcrIl1Hex61E4gI6Y7f9jhgO/mYAWI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579283330; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=p2DHulXAzbflIx/FnNlkAuHbFuQu7ul5nXBDX4BnnfU=; b=ju9Is/iuhVotbwvNrZ3fyl04wOIEzuFjUP8CjCLig2uRV9IbygLv8f4NU+dq27B8Wxf5XwLYcC3i1CvgRAHl0T9PDkSgttPKOVCfDLdbA1KhzPquxZ+Oee/nnWBHVyZkXD4cZS/Eod9qlX6U0QgFoEhmpaf8134NcKm3/KCZIpI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579283330578666.4747334215893; Fri, 17 Jan 2020 09:48:50 -0800 (PST) Received: from localhost ([::1]:32872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isVjk-0003tO-BW for importer@patchew.org; Fri, 17 Jan 2020 12:48:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55818) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isVi3-0002Gn-RQ for qemu-devel@nongnu.org; Fri, 17 Jan 2020 12:47:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1isVi2-0007i0-Bg for qemu-devel@nongnu.org; Fri, 17 Jan 2020 12:47:03 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:58596 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1isVhw-0007YV-UC; Fri, 17 Jan 2020 12:46:57 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 927695ACAEEA5F968A62; Sat, 18 Jan 2020 01:46:51 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Sat, 18 Jan 2020 01:46:44 +0800 From: Shameer Kolothum To: , , , Subject: [PATCH v2 2/7] hw/acpi/nvdimm: Fix for NVDIMM incorrect DSM output buffer length Date: Fri, 17 Jan 2020 17:45:17 +0000 Message-ID: <20200117174522.22044-3-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20200117174522.22044-1-shameerali.kolothum.thodi@huawei.com> References: <20200117174522.22044-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 45.249.212.32 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@linaro.org, xiaoguangrong.eric@gmail.com, mst@redhat.com, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As per ACPI spec 6.3, Table 19-419 Object Conversion Rules, if the Buffer Field <=3D to the size of an Integer (in bits), it will be treated as an integer. Moreover, the integer size depends on DSDT tables revision number. If revision number is < 2, integer size is 32 bits, otherwise it is 64 bits. Current NVDIMM common DSM aml code (NCAL) uses CreateField() for creating DSM output buffer. This creates an issue in arm/virt platform where DSDT revision number is 2 and results in DSM buffer with a wrong size(8 bytes) gets returned when actual length is < 8 bytes. This causes guest kernel to report, "nfit ACPI0012:00: found a zero length table '0' parsing nfit" In order to fix this, aml code is now modified such that it builds the DSM output buffer in a byte by byte fashion when length is smaller than Integer size. Suggested-by: Igor Mammedov Signed-off-by: Shameer Kolothum --- Please find the previous discussion on this here, https://patchwork.kernel.org/cover/11174959/ --- hw/acpi/nvdimm.c | 36 +++++++++++++++++++-- tests/qtest/bios-tables-test-allowed-diff.h | 2 ++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 9fdad6dc3f..5e7b8318d0 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -964,6 +964,7 @@ static void nvdimm_build_common_dsm(Aml *dev) Aml *method, *ifctx, *function, *handle, *uuid, *dsm_mem, *elsectx2; Aml *elsectx, *unsupport, *unpatched, *expected_uuid, *uuid_invalid; Aml *pckg, *pckg_index, *pckg_buf, *field, *dsm_out_buf, *dsm_out_buf_= size; + Aml *whilectx, *offset; uint8_t byte_list[1]; =20 method =3D aml_method(NVDIMM_COMMON_DSM, 5, AML_SERIALIZED); @@ -1117,13 +1118,42 @@ static void nvdimm_build_common_dsm(Aml *dev) /* RLEN is not included in the payload returned to guest. */ aml_append(method, aml_subtract(aml_name(NVDIMM_DSM_OUT_BUF_SIZE), aml_int(4), dsm_out_buf_size)); + + /* + * As per ACPI spec 6.3, Table 19-419 Object Conversion Rules, if + * the Buffer Field <=3D to the size of an Integer (in bits), it will + * be treated as an integer. Moreover, the integer size depends on + * DSDT tables revision number. If revision number is < 2, integer + * size is 32 bits, otherwise it is 64 bits. + * Because of this CreateField() canot be used if RLEN < Integer Size. + * Hence build dsm_out_buf byte by byte. + */ + ifctx =3D aml_if(aml_lless(dsm_out_buf_size, aml_sizeof(aml_int(0)))); + offset =3D aml_local(2); + aml_append(ifctx, aml_store(aml_int(0), offset)); + aml_append(ifctx, aml_name_decl("TBUF", aml_buffer(1, NULL))); + aml_append(ifctx, aml_store(aml_buffer(0, NULL), dsm_out_buf)); + + whilectx =3D aml_while(aml_lless(offset, dsm_out_buf_size)); + /* Copy 1 byte at offset from ODAT to temporary buffer(TBUF). */ + aml_append(whilectx, aml_store(aml_derefof(aml_index( + aml_name(NVDIMM_DSM_OUT_BUF), offset)), + aml_index(aml_name("TBUF"), aml_int(0))= )); + aml_append(whilectx, aml_concatenate(dsm_out_buf, aml_name("TBUF"), + dsm_out_buf)); + aml_append(whilectx, aml_increment(offset)); + aml_append(ifctx, whilectx); + + aml_append(ifctx, aml_return(dsm_out_buf)); + aml_append(method, ifctx); + + /* If RLEN >=3D Integer size, just use CreateField() operator */ aml_append(method, aml_store(aml_shiftleft(dsm_out_buf_size, aml_int(3= )), dsm_out_buf_size)); aml_append(method, aml_create_field(aml_name(NVDIMM_DSM_OUT_BUF), aml_int(0), dsm_out_buf_size, "OBUF")); - aml_append(method, aml_concatenate(aml_buffer(0, NULL), aml_name("OBUF= "), - dsm_out_buf)); - aml_append(method, aml_return(dsm_out_buf)); + aml_append(method, aml_return(aml_name("OBUF"))); + aml_append(dev, method); } =20 diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..eb8bae1407 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,3 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/SSDT.dimmpxm", +"tests/data/acpi/q35/SSDT.dimmpxm", --=20 2.17.1 From nobody Sat Apr 27 11:19:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1579283608; cv=none; d=zohomail.com; s=zohoarc; b=ecu8kLr3S62Y0qWApsjvE8ke7AdLJ5jJ1aNDB4e3Ln2Sp4aaX1mGyA7zXGd2MwcQEjcTckRKTHxxqH1oPBnsyZuOPrUl3lCTuttBTtmw5n9J48RMHu/OKlpYYjb7y9cYpQfUaUcUNmU0jQdfnc7cIIsWwkKBOMle5yJpeMuHvzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579283608; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=D/FUcsYlq3XqMKaAYr/YENk66tD3MgAKqEOIsibgRog=; b=GpZ8futzc537tguZloYcEsPUdgmaAemgeTj03C7GKb3IDW2kjmllGn105O0yv0nXDm0+pzsWznNj2ExAYFAQxWr5DBuwne5R89YFmC+Vbg9mX+8aEDU4nl+wv9IzCTFwG6tfVtGySgRjleqz2FLCEcxk7iDy1JiRoRxTknv59Xo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579283608198421.1120814820008; Fri, 17 Jan 2020 09:53:28 -0800 (PST) Received: from localhost ([::1]:32924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isVnS-0000R0-Bd for importer@patchew.org; Fri, 17 Jan 2020 12:52:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55820) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isVi3-0002Gp-S6 for qemu-devel@nongnu.org; Fri, 17 Jan 2020 12:47:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1isVi2-0007hv-BQ for qemu-devel@nongnu.org; Fri, 17 Jan 2020 12:47:03 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:47146 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1isVhy-0007cB-JC; Fri, 17 Jan 2020 12:46:59 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A0FD2421712A17BED3AA; Sat, 18 Jan 2020 01:46:56 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Sat, 18 Jan 2020 01:46:47 +0800 From: Shameer Kolothum To: , , , Subject: [PATCH v2 3/7] nvdimm: Use configurable ACPI IO base and size Date: Fri, 17 Jan 2020 17:45:18 +0000 Message-ID: <20200117174522.22044-4-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20200117174522.22044-1-shameerali.kolothum.thodi@huawei.com> References: <20200117174522.22044-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 45.249.212.35 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@linaro.org, xiaoguangrong.eric@gmail.com, mst@redhat.com, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kwangwoo Lee This patch makes IO base and size configurable to create NPIO AML for ACPI NFIT. Since a different architecture like AArch64 does not use port-mapped IO, a configurable IO base is required to create correct mapping of ACPI IO address and size. Signed-off-by: Kwangwoo Lee Signed-off-by: Eric Auger Signed-off-by: Shameer Kolothum --- hw/acpi/nvdimm.c | 32 ++++++++++++++++++++++---------- hw/i386/acpi-build.c | 6 ++++++ hw/i386/acpi-build.h | 3 +++ hw/i386/pc_piix.c | 2 ++ hw/i386/pc_q35.c | 2 ++ include/hw/mem/nvdimm.h | 3 +++ 6 files changed, 38 insertions(+), 10 deletions(-) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 5e7b8318d0..c28c665b13 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -926,11 +926,13 @@ void nvdimm_acpi_plug_cb(HotplugHandler *hotplug_dev,= DeviceState *dev) } =20 void nvdimm_init_acpi_state(NVDIMMState *state, MemoryRegion *io, + struct AcpiGenericAddress dsm_io, FWCfgState *fw_cfg, Object *owner) { + state->dsm_io =3D dsm_io; memory_region_init_io(&state->io_mr, owner, &nvdimm_dsm_ops, state, - "nvdimm-acpi-io", NVDIMM_ACPI_IO_LEN); - memory_region_add_subregion(io, NVDIMM_ACPI_IO_BASE, &state->io_mr); + "nvdimm-acpi-io", dsm_io.bit_width >> 3); + memory_region_add_subregion(io, dsm_io.address, &state->io_mr); =20 state->dsm_mem =3D g_array_new(false, true /* clear */, 1); acpi_data_push(state->dsm_mem, sizeof(NvdimmDsmIn)); @@ -959,13 +961,15 @@ void nvdimm_init_acpi_state(NVDIMMState *state, Memor= yRegion *io, =20 #define NVDIMM_QEMU_RSVD_UUID "648B9CF2-CDA1-4312-8AD9-49C4AF32BD62" =20 -static void nvdimm_build_common_dsm(Aml *dev) +static void nvdimm_build_common_dsm(Aml *dev, + NVDIMMState *nvdimm_state) { Aml *method, *ifctx, *function, *handle, *uuid, *dsm_mem, *elsectx2; Aml *elsectx, *unsupport, *unpatched, *expected_uuid, *uuid_invalid; Aml *pckg, *pckg_index, *pckg_buf, *field, *dsm_out_buf, *dsm_out_buf_= size; Aml *whilectx, *offset; uint8_t byte_list[1]; + AmlRegionSpace rs; =20 method =3D aml_method(NVDIMM_COMMON_DSM, 5, AML_SERIALIZED); uuid =3D aml_arg(0); @@ -976,9 +980,16 @@ static void nvdimm_build_common_dsm(Aml *dev) =20 aml_append(method, aml_store(aml_name(NVDIMM_ACPI_MEM_ADDR), dsm_mem)); =20 + if (nvdimm_state->dsm_io.space_id =3D=3D AML_AS_SYSTEM_IO) { + rs =3D AML_SYSTEM_IO; + } else { + rs =3D AML_SYSTEM_MEMORY; + } + /* map DSM memory and IO into ACPI namespace. */ - aml_append(method, aml_operation_region(NVDIMM_DSM_IOPORT, AML_SYSTEM_= IO, - aml_int(NVDIMM_ACPI_IO_BASE), NVDIMM_ACPI_IO_LEN)); + aml_append(method, aml_operation_region(NVDIMM_DSM_IOPORT, rs, + aml_int(nvdimm_state->dsm_io.address), + nvdimm_state->dsm_io.bit_width >> 3)); aml_append(method, aml_operation_region(NVDIMM_DSM_MEMORY, AML_SYSTEM_MEMORY, dsm_mem, sizeof(NvdimmDsmIn))); =20 @@ -993,7 +1004,7 @@ static void nvdimm_build_common_dsm(Aml *dev) field =3D aml_field(NVDIMM_DSM_IOPORT, AML_DWORD_ACC, AML_NOLOCK, AML_PRESERVE); aml_append(field, aml_named_field(NVDIMM_DSM_NOTIFY, - NVDIMM_ACPI_IO_LEN * BITS_PER_BYTE)); + nvdimm_state->dsm_io.bit_width)); aml_append(method, field); =20 /* @@ -1290,7 +1301,8 @@ static void nvdimm_build_nvdimm_devices(Aml *root_dev= , uint32_t ram_slots) } =20 static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data, - BIOSLinker *linker, GArray *dsm_dma_area, + BIOSLinker *linker, + NVDIMMState *nvdimm_state, uint32_t ram_slots) { Aml *ssdt, *sb_scope, *dev; @@ -1318,7 +1330,7 @@ static void nvdimm_build_ssdt(GArray *table_offsets, = GArray *table_data, */ aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0012"))); =20 - nvdimm_build_common_dsm(dev); + nvdimm_build_common_dsm(dev, nvdimm_state); =20 /* 0 is reserved for root device. */ nvdimm_build_device_dsm(dev, 0); @@ -1337,7 +1349,7 @@ static void nvdimm_build_ssdt(GArray *table_offsets, = GArray *table_data, NVDIMM_ACPI_MEM_ADDR); =20 bios_linker_loader_alloc(linker, - NVDIMM_DSM_MEM_FILE, dsm_dma_area, + NVDIMM_DSM_MEM_FILE, nvdimm_state->dsm_mem, sizeof(NvdimmDsmIn), false /* high memory */); bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, mem_addr_offset, sizeof(uint32_t), @@ -1359,7 +1371,7 @@ void nvdimm_build_acpi(GArray *table_offsets, GArray = *table_data, return; } =20 - nvdimm_build_ssdt(table_offsets, table_data, linker, state->dsm_mem, + nvdimm_build_ssdt(table_offsets, table_data, linker, state, ram_slots); =20 device_list =3D nvdimm_get_device_list(); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index e25df838f0..e75f213470 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -127,6 +127,12 @@ typedef struct FwCfgTPMConfig { =20 static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg); =20 +const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio =3D { + .space_id =3D AML_AS_SYSTEM_IO, + .address =3D NVDIMM_ACPI_IO_BASE, + .bit_width =3D NVDIMM_ACPI_IO_LEN << 3 +}; + static void init_common_fadt_data(MachineState *ms, Object *o, AcpiFadtData *data) { diff --git a/hw/i386/acpi-build.h b/hw/i386/acpi-build.h index 007332e51c..74df5fc612 100644 --- a/hw/i386/acpi-build.h +++ b/hw/i386/acpi-build.h @@ -1,6 +1,9 @@ =20 #ifndef HW_I386_ACPI_BUILD_H #define HW_I386_ACPI_BUILD_H +#include "hw/acpi/acpi-defs.h" + +extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio; =20 void acpi_setup(void); =20 diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index fa12203079..22032a1f4a 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -60,6 +60,7 @@ #include "migration/global_state.h" #include "migration/misc.h" #include "sysemu/numa.h" +#include "hw/i386/acpi-build.h" =20 #define MAX_IDE_BUS 2 =20 @@ -296,6 +297,7 @@ else { =20 if (machine->nvdimms_state->is_enabled) { nvdimm_init_acpi_state(machine->nvdimms_state, system_io, + x86_nvdimm_acpi_dsmio, x86ms->fw_cfg, OBJECT(pcms)); } } diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 84cf925cf4..01a334b038 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -53,6 +53,7 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "sysemu/numa.h" +#include "hw/i386/acpi-build.h" =20 /* ICH9 AHCI has 6 ports */ #define MAX_SATA_PORTS 6 @@ -314,6 +315,7 @@ static void pc_q35_init(MachineState *machine) =20 if (machine->nvdimms_state->is_enabled) { nvdimm_init_acpi_state(machine->nvdimms_state, system_io, + x86_nvdimm_acpi_dsmio, x86ms->fw_cfg, OBJECT(pcms)); } } diff --git a/include/hw/mem/nvdimm.h b/include/hw/mem/nvdimm.h index 523a9b3d4a..5fe440861e 100644 --- a/include/hw/mem/nvdimm.h +++ b/include/hw/mem/nvdimm.h @@ -25,6 +25,7 @@ =20 #include "hw/mem/pc-dimm.h" #include "hw/acpi/bios-linker-loader.h" +#include "hw/acpi/aml-build.h" =20 #define NVDIMM_DEBUG 0 #define nvdimm_debug(fmt, ...) \ @@ -140,10 +141,12 @@ struct NVDIMMState { */ int32_t persistence; char *persistence_string; + struct AcpiGenericAddress dsm_io; }; typedef struct NVDIMMState NVDIMMState; =20 void nvdimm_init_acpi_state(NVDIMMState *state, MemoryRegion *io, + struct AcpiGenericAddress dsm_io, FWCfgState *fw_cfg, Object *owner); void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data, BIOSLinker *linker, NVDIMMState *state, --=20 2.17.1 From nobody Sat Apr 27 11:19:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1579283467; cv=none; d=zohomail.com; s=zohoarc; b=A/hNdWWNY/9A+neo7oZqAWInmbk/N/aAnTfmli5EAXiNk0nay7ER8ju+UkIDJLox7M92+5/EqcUIM/Jo7eMqCgZboLCs+FkI/ctNcM271/eFQfQeMdMM1/yFn/t8VY0crr6ynMX9Z6Aorah3IICJk98ICMZkOXdmEhDzFkgO+Ig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579283467; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=o8VDxzGgP7y5GkC9vBPdWVS+DRRuC2hryUh73+TVkZo=; b=hLexjy1bHum260NxErrAkYVy8tfozi5A0jWSq73FAUYVlhQxCYwxFRRFGwM189xL0Fkztto7PAumrZtNDGx20fx6TNsIqYKfW1jQxlANKYfYP63e4qTStwmOfNLA1fYFk2XH++QzDSHN15Ds8lwF0lsdskS+BF1D/YLT6+fggPw= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579283467744577.365818263932; Fri, 17 Jan 2020 09:51:07 -0800 (PST) Received: from localhost ([::1]:32910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isVly-0006oS-Lo for importer@patchew.org; Fri, 17 Jan 2020 12:51:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55873) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isVi8-0002MA-3v for qemu-devel@nongnu.org; Fri, 17 Jan 2020 12:47:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1isVi6-0007mL-LE for qemu-devel@nongnu.org; Fri, 17 Jan 2020 12:47:07 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:47266 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1isVi3-0007hV-L0; Fri, 17 Jan 2020 12:47:03 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B288129EE4A26EDCDC6E; Sat, 18 Jan 2020 01:47:01 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Sat, 18 Jan 2020 01:46:51 +0800 From: Shameer Kolothum To: , , , Subject: [PATCH v2 4/7] hw/arm/virt: Add nvdimm hot-plug infrastructure Date: Fri, 17 Jan 2020 17:45:19 +0000 Message-ID: <20200117174522.22044-5-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20200117174522.22044-1-shameerali.kolothum.thodi@huawei.com> References: <20200117174522.22044-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 45.249.212.35 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@linaro.org, xiaoguangrong.eric@gmail.com, mst@redhat.com, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kwangwoo Lee Prepare pre-plug and plug handlers for NVDIMM support. Please note nvdimm_support is not yet enabled. Signed-off-by: Kwangwoo Lee Signed-off-by: Eric Auger Signed-off-by: Shameer Kolothum --- hw/arm/Kconfig | 1 + hw/arm/virt-acpi-build.c | 6 ++++++ hw/arm/virt.c | 19 +++++++++++++++++++ hw/mem/Kconfig | 2 +- include/hw/arm/virt.h | 1 + 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index c6e7782580..851dd81289 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -24,6 +24,7 @@ config ARM_VIRT select DIMM select ACPI_MEMORY_HOTPLUG select ACPI_HW_REDUCED + select ACPI_NVDIMM =20 config CHEETAH bool diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index bd5f771e9b..c51eae549e 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -44,6 +44,7 @@ #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" #include "hw/arm/virt.h" +#include "hw/mem/nvdimm.h" #include "sysemu/numa.h" #include "sysemu/reset.h" #include "kvm_arm.h" @@ -839,6 +840,11 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildT= ables *tables) } } =20 + if (ms->nvdimms_state->is_enabled) { + nvdimm_build_acpi(table_offsets, tables_blob, tables->linker, + ms->nvdimms_state, ms->ram_slots); + } + if (its_class_name() && !vmc->no_its) { acpi_add_table(table_offsets, tables_blob); build_iort(tables_blob, tables->linker, vms); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 39ab5f47e0..7987c8f5b8 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -143,6 +143,7 @@ static const MemMapEntry base_memmap[] =3D { [VIRT_SMMU] =3D { 0x09050000, 0x00020000 }, [VIRT_PCDIMM_ACPI] =3D { 0x09070000, MEMORY_HOTPLUG_IO_LEN }, [VIRT_ACPI_GED] =3D { 0x09080000, ACPI_GED_EVT_SEL_LEN }, + [VIRT_NVDIMM_ACPI] =3D { 0x09090000, NVDIMM_ACPI_IO_LEN}, [VIRT_MMIO] =3D { 0x0a000000, 0x00000200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that siz= e */ [VIRT_PLATFORM_BUS] =3D { 0x0c000000, 0x02000000 }, @@ -1749,6 +1750,18 @@ static void machvirt_init(MachineState *machine) =20 create_platform_bus(vms); =20 + if (machine->nvdimms_state->is_enabled) { + const struct AcpiGenericAddress arm_virt_nvdimm_acpi_dsmio =3D { + .space_id =3D AML_AS_SYSTEM_MEMORY, + .address =3D vms->memmap[VIRT_NVDIMM_ACPI].base, + .bit_width =3D NVDIMM_ACPI_IO_LEN << 3 + }; + + nvdimm_init_acpi_state(machine->nvdimms_state, sysmem, + arm_virt_nvdimm_acpi_dsmio, + vms->fw_cfg, OBJECT(vms)); + } + vms->bootinfo.ram_size =3D machine->ram_size; vms->bootinfo.nb_cpus =3D smp_cpus; vms->bootinfo.board_id =3D -1; @@ -1936,6 +1949,8 @@ static void virt_memory_plug(HotplugHandler *hotplug_= dev, { HotplugHandlerClass *hhc; VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); + MachineState *ms =3D MACHINE(hotplug_dev); + bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); Error *local_err =3D NULL; =20 pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err); @@ -1943,6 +1958,10 @@ static void virt_memory_plug(HotplugHandler *hotplug= _dev, goto out; } =20 + if (is_nvdimm) { + nvdimm_plug(ms->nvdimms_state); + } + hhc =3D HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev); hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &error_abort); out: diff --git a/hw/mem/Kconfig b/hw/mem/Kconfig index 620fd4cb59..0d5f8f321a 100644 --- a/hw/mem/Kconfig +++ b/hw/mem/Kconfig @@ -8,4 +8,4 @@ config MEM_DEVICE config NVDIMM bool default y - depends on PC + depends on PC || ARM_VIRT diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 38f0c33c77..9c9eaaa89d 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -79,6 +79,7 @@ enum { VIRT_SECURE_MEM, VIRT_PCDIMM_ACPI, VIRT_ACPI_GED, + VIRT_NVDIMM_ACPI, VIRT_LOWMEMMAP_LAST, }; =20 --=20 2.17.1 From nobody Sat Apr 27 11:19:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1579283676; cv=none; d=zohomail.com; s=zohoarc; b=Yt6GckQfpHkxyKmaDWuEbauSDVJul2l/LcSMaf3Xy959/0nBA5DwDExfxncT0SaFFFjiOJIyP41WJoYv8ee0umMSyKo0Re6j2I9aQci7PRDbWYugonCKAPasvX1rILLLEYMrhrPcGlbQkswTKJtpzca2OTJyRwlBIQjaiGTEkOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579283676; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IuIuk8ekEYIUyjhEeUTFMbxCxDmbLOlJPwRxow9DgXc=; b=igelmtRUi8YsGiRLcRaSgjKyRXesBlJKSYIVTmRfFdD5c+9bAJ6piuHp1+KYe8mlLtTE7Zc1oZKDb8aN825PrD+dRCyjKVeGUgPUd8njADjKO6+boRSvAohg8coJR+BxC2rxzlfqZRlN+B+eU/tZiMg2loCvApCqmQt0fpb2GJg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157928367629271.29550353413765; Fri, 17 Jan 2020 09:54:36 -0800 (PST) Received: from localhost ([::1]:32922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isVnK-0000F7-JH for importer@patchew.org; Fri, 17 Jan 2020 12:52:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55891) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isViA-0002Pv-FU for qemu-devel@nongnu.org; Fri, 17 Jan 2020 12:47:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1isVi9-0007p8-3R for qemu-devel@nongnu.org; Fri, 17 Jan 2020 12:47:10 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:47276 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1isVi3-0007hZ-MN; Fri, 17 Jan 2020 12:47:03 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B9288ADAA69314790517; Sat, 18 Jan 2020 01:47:01 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Sat, 18 Jan 2020 01:46:54 +0800 From: Shameer Kolothum To: , , , Subject: [PATCH v2 5/7] hw/arm/virt: Add nvdimm hotplug support Date: Fri, 17 Jan 2020 17:45:20 +0000 Message-ID: <20200117174522.22044-6-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20200117174522.22044-1-shameerali.kolothum.thodi@huawei.com> References: <20200117174522.22044-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 45.249.212.35 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@linaro.org, xiaoguangrong.eric@gmail.com, mst@redhat.com, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This adds support for nvdimm hotplug events through GED and enables nvdimm for the arm/virt. Now Guests with ACPI can have both cold and hot plug of nvdimms. Hot removal functionality is not yet supported. Signed-off-by: Shameer Kolothum Reviewed-by: Igor Mammedov Reviewed-by: Eric Auger --- docs/specs/acpi_hw_reduced_hotplug.rst | 1 + hw/acpi/generic_event_device.c | 13 +++++++++++++ hw/arm/virt.c | 16 +++++++++++----- include/hw/acpi/generic_event_device.h | 1 + 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/docs/specs/acpi_hw_reduced_hotplug.rst b/docs/specs/acpi_hw_re= duced_hotplug.rst index 911a98255b..e3abe975bf 100644 --- a/docs/specs/acpi_hw_reduced_hotplug.rst +++ b/docs/specs/acpi_hw_reduced_hotplug.rst @@ -63,6 +63,7 @@ GED IO interface (4 byte access) bits: 0: Memory hotplug event 1: System power down event + 2: NVDIMM hotplug event 2-31: Reserved =20 **write_access:** diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 9cee90cc70..ad1b684304 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -16,6 +16,7 @@ #include "hw/acpi/generic_event_device.h" #include "hw/irq.h" #include "hw/mem/pc-dimm.h" +#include "hw/mem/nvdimm.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h" #include "qemu/error-report.h" @@ -23,6 +24,7 @@ static const uint32_t ged_supported_events[] =3D { ACPI_GED_MEM_HOTPLUG_EVT, ACPI_GED_PWR_DOWN_EVT, + ACPI_GED_NVDIMM_HOTPLUG_EVT, }; =20 /* @@ -110,6 +112,11 @@ void build_ged_aml(Aml *table, const char *name, Hotpl= ugHandler *hotplug_dev, aml_notify(aml_name(ACPI_POWER_BUTTON_DEVICE), aml_int(0x80))); break; + case ACPI_GED_NVDIMM_HOTPLUG_EVT: + aml_append(if_ctx, + aml_notify(aml_name("\\_SB.NVDR"), + aml_int(0x80))); + break; default: /* * Please make sure all the events in ged_supported_events= [] @@ -175,7 +182,11 @@ static void acpi_ged_device_plug_cb(HotplugHandler *ho= tplug_dev, AcpiGedState *s =3D ACPI_GED(hotplug_dev); =20 if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) { + nvdimm_acpi_plug_cb(hotplug_dev, dev); + } else { acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, dev, errp); + } } else { error_setg(errp, "virt: device plug request for unsupported device" " type: %s", object_get_typename(OBJECT(dev))); @@ -192,6 +203,8 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, Acp= iEventStatusBits ev) sel =3D ACPI_GED_MEM_HOTPLUG_EVT; } else if (ev & ACPI_POWER_DOWN_STATUS) { sel =3D ACPI_GED_PWR_DOWN_EVT; + } else if (ev & ACPI_NVDIMM_HOTPLUG_STATUS) { + sel =3D ACPI_GED_NVDIMM_HOTPLUG_EVT; } else { /* Unknown event. Return without generating interrupt. */ warn_report("GED: Unsupported event %d. No irq injected", ev); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 7987c8f5b8..5ea2584491 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -543,6 +543,10 @@ static inline DeviceState *create_acpi_ged(VirtMachine= State *vms) event |=3D ACPI_GED_MEM_HOTPLUG_EVT; } =20 + if (ms->nvdimms_state->is_enabled) { + event |=3D ACPI_GED_NVDIMM_HOTPLUG_EVT; + } + dev =3D qdev_create(NULL, TYPE_ACPI_GED); qdev_prop_set_uint32(dev, "ged-event", event); =20 @@ -1928,19 +1932,20 @@ static void virt_memory_pre_plug(HotplugHandler *ho= tplug_dev, DeviceState *dev, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); + const MachineState *ms =3D MACHINE(hotplug_dev); const bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); =20 - if (is_nvdimm) { - error_setg(errp, "nvdimm is not yet supported"); - return; - } - if (!vms->acpi_dev) { error_setg(errp, "memory hotplug is not enabled: missing acpi-ged device= "); return; } =20 + if (is_nvdimm && !ms->nvdimms_state->is_enabled) { + error_setg(errp, "nvdimm is not enabled: missing 'nvdimm' in '-M'"= ); + return; + } + pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), NULL, errp); } =20 @@ -2071,6 +2076,7 @@ static void virt_machine_class_init(ObjectClass *oc, = void *data) hc->plug =3D virt_machine_device_plug_cb; hc->unplug_request =3D virt_machine_device_unplug_request_cb; mc->numa_mem_supported =3D true; + mc->nvdimm_supported =3D true; mc->auto_enable_numa_with_memhp =3D true; } =20 diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/gener= ic_event_device.h index d157eac088..9eb86ca4fd 100644 --- a/include/hw/acpi/generic_event_device.h +++ b/include/hw/acpi/generic_event_device.h @@ -82,6 +82,7 @@ */ #define ACPI_GED_MEM_HOTPLUG_EVT 0x1 #define ACPI_GED_PWR_DOWN_EVT 0x2 +#define ACPI_GED_NVDIMM_HOTPLUG_EVT 0x4 =20 typedef struct GEDState { MemoryRegion io; --=20 2.17.1 From nobody Sat Apr 27 11:19:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1579283356; cv=none; d=zohomail.com; s=zohoarc; b=g9zaKNGbr7fpxiNAxb3O5EgHyuhE1UrD4wJQmc4CajAxnmILn3lLZrxN2pBU02eZSEBE9tcX1B0SJqUNUl4iKZZsGtmnPQxYMHwk2jdgXuNwKSuJ5gzPYJwypce1yGcNHOM5aH379hr0vHQcIHPUtGqqMyAfj6tl6Zc5azhlUY4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579283356; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CY1kSJsdUIlx2KqncdHsa930Tu3O6KEWkoSKcE5dot0=; b=EgnV6wS0jXIgQQa/0shsLDhlD1uWklyqbx+xYRCSmhG/yrC8WwZzngbgcd7t3kVi9HXlktnTXdtejNiHXzOEGL7WlydtgZ1QVs+b0ZKwyvF8R9ONngNNS4ZMo1YuNEHQMwqB/vtBsIjIh9tlr6DjZvNnXVjBXgZWfvLtMcra/PI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579283356726176.81553159021757; Fri, 17 Jan 2020 09:49:16 -0800 (PST) Received: from localhost ([::1]:32877 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isVkB-0004WM-Mi for importer@patchew.org; Fri, 17 Jan 2020 12:49:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55913) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isViE-0002Vn-OB for qemu-devel@nongnu.org; Fri, 17 Jan 2020 12:47:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1isViD-0007tM-JY for qemu-devel@nongnu.org; Fri, 17 Jan 2020 12:47:14 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2685 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1isVi9-0007mm-MN; Fri, 17 Jan 2020 12:47:09 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id C5B45D4814A9FEF4AEFA; Sat, 18 Jan 2020 01:47:06 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Sat, 18 Jan 2020 01:46:57 +0800 From: Shameer Kolothum To: , , , Subject: [PATCH v2 6/7] tests: Update ACPI tables list for upcoming arm/virt test changes Date: Fri, 17 Jan 2020 17:45:21 +0000 Message-ID: <20200117174522.22044-7-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20200117174522.22044-1-shameerali.kolothum.thodi@huawei.com> References: <20200117174522.22044-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 45.249.212.190 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@linaro.org, xiaoguangrong.eric@gmail.com, mst@redhat.com, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This is in preparation to update test_acpi_virt_tcg_memhp() with pc-dimm and nvdimm. Update the bios-tables-test-allowed-diff.h with the affected ACPI tables so that "make check" doesn't fail. Signed-off-by: Shameer Kolothum --- tests/qtest/bios-tables-test-allowed-diff.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index eb8bae1407..862c49e675 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,3 +1,6 @@ /* List of comma-separated changed AML files to ignore */ "tests/data/acpi/pc/SSDT.dimmpxm", "tests/data/acpi/q35/SSDT.dimmpxm", +"tests/data/acpi/virt/DSDT.memhp", +"tests/data/acpi/virt/SSDT.memhp", +"tests/data/acpi/virt/NFIT.memhp", --=20 2.17.1 From nobody Sat Apr 27 11:19:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1579283639; cv=none; d=zohomail.com; s=zohoarc; b=JNS0lZR/y85y25sfTPms27ORf8mH6xAFa36jrur/fqVQmAIcBd51jINfCqragV4OpIXEGOcNn6uXuqUmGVAEq8yBO1o+OdrR8ActywDMObjnWygs6AZiEnGw39PNP22H1A8/xulKW4Db/VbFAGNrOBNwHNLXoc5oso65Uy1OM4o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579283639; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rfZK6f0P/M2o7DyT+klLSfhB7SJ2LY0hMYqYaCeerqg=; b=fXrWZfrXJuKRqdEDXztFwaggNIi31BzIDVWmKZVCAAPF1kfyU2/KQVD/u9ND+czW4j3Z9Ip91CbWHE+T6CxKeOiKbbX0Mrto1mt61KbIc5E3juJlaApS0Ay04CnNMWialoLzj3ZChkebo0A2FPtxQwXTcviwLnhlX5eDrtstV2s= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579283639418906.2131401333993; Fri, 17 Jan 2020 09:53:59 -0800 (PST) Received: from localhost ([::1]:32962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isVoj-0002DN-9v for importer@patchew.org; Fri, 17 Jan 2020 12:53:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55939) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isViI-0002cM-Gt for qemu-devel@nongnu.org; Fri, 17 Jan 2020 12:47:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1isViH-0007wi-D6 for qemu-devel@nongnu.org; Fri, 17 Jan 2020 12:47:18 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2742 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1isViE-0007sI-LM; Fri, 17 Jan 2020 12:47:14 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D8FA28F48DA91834DA0B; Sat, 18 Jan 2020 01:47:11 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Sat, 18 Jan 2020 01:47:00 +0800 From: Shameer Kolothum To: , , , Subject: [PATCH v2 7/7] tests/bios-tables-test: Update arm/virt memhp test Date: Fri, 17 Jan 2020 17:45:22 +0000 Message-ID: <20200117174522.22044-8-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20200117174522.22044-1-shameerali.kolothum.thodi@huawei.com> References: <20200117174522.22044-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 45.249.212.191 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@linaro.org, xiaoguangrong.eric@gmail.com, mst@redhat.com, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since we now have both pc-dimm and nvdimm support, update test_acpi_virt_tcg_memhp() to include those. Signed-off-by: Shameer Kolothum --- tests/data/acpi/virt/NFIT.memhp | 0 tests/data/acpi/virt/SSDT.memhp | 0 tests/qtest/bios-tables-test.c | 9 +++++++-- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 tests/data/acpi/virt/NFIT.memhp create mode 100644 tests/data/acpi/virt/SSDT.memhp diff --git a/tests/data/acpi/virt/NFIT.memhp b/tests/data/acpi/virt/NFIT.me= mhp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/virt/SSDT.memhp b/tests/data/acpi/virt/SSDT.me= mhp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index f1ac2d7e96..695d2e7fac 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -913,12 +913,17 @@ static void test_acpi_virt_tcg_memhp(void) }; =20 data.variant =3D ".memhp"; - test_acpi_one(" -cpu cortex-a57" + test_acpi_one(" -machine nvdimm=3Don" + " -cpu cortex-a57" " -m 256M,slots=3D3,maxmem=3D1G" " -object memory-backend-ram,id=3Dram0,size=3D128M" " -object memory-backend-ram,id=3Dram1,size=3D128M" " -numa node,memdev=3Dram0 -numa node,memdev=3Dram1" - " -numa dist,src=3D0,dst=3D1,val=3D21", + " -numa dist,src=3D0,dst=3D1,val=3D21" + " -object memory-backend-ram,id=3Dram2,size=3D128M" + " -object memory-backend-ram,id=3Dnvm0,size=3D128M" + " -device pc-dimm,id=3Ddimm0,memdev=3Dram2,node=3D0" + " -device nvdimm,id=3Ddimm1,memdev=3Dnvm0,node=3D1", &data); =20 free_test_data(&data); --=20 2.17.1