From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zls3l-0002np-I1 for qemu-devel@nongnu.org; Tue, 13 Oct 2015 01:23:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zls3g-0005a8-Jz for qemu-devel@nongnu.org; Tue, 13 Oct 2015 01:23:37 -0400 Received: from mga09.intel.com ([134.134.136.24]:46738) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zls3g-0005a1-9d for qemu-devel@nongnu.org; Tue, 13 Oct 2015 01:23:32 -0400 References: <1444535584-18220-1-git-send-email-guangrong.xiao@linux.intel.com> <1444535584-18220-24-git-send-email-guangrong.xiao@linux.intel.com> From: Xiao Guangrong Message-ID: <561C93E0.6080602@linux.intel.com> Date: Tue, 13 Oct 2015 13:17:20 +0800 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 23/32] nvdimm: build ACPI NFIT table List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Dan Williams Cc: ehabkost@redhat.com, KVM list , "Michael S. Tsirkin" , Gleb Natapov , mtosatti@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, imammedo@redhat.com, Paolo Bonzini , rth@twiddle.net On 10/13/2015 12:40 AM, Dan Williams wrote: > On Sat, Oct 10, 2015 at 8:52 PM, Xiao Guangrong > wrote: >> NFIT is defined in ACPI 6.0: 5.2.25 NVDIMM Firmware Interface Table (NFIT) >> >> Currently, we only support PMEM mode. Each device has 3 structures: >> - SPA structure, defines the PMEM region info >> >> - MEM DEV structure, it has the @handle which is used to associate specified >> ACPI NVDIMM device we will introduce in later patch. >> Also we can happily ignored the memory device's interleave, the real >> nvdimm hardware access is hidden behind host >> >> - DCR structure, it defines vendor ID used to associate specified vendor >> nvdimm driver. Since we only implement PMEM mode this time, Command >> window and Data window are not needed >> >> Signed-off-by: Xiao Guangrong >> --- >> hw/i386/acpi-build.c | 4 + >> hw/mem/nvdimm/acpi.c | 209 ++++++++++++++++++++++++++++++++++++++++++++++- >> hw/mem/nvdimm/internal.h | 13 +++ >> hw/mem/nvdimm/nvdimm.c | 25 ++++++ >> include/hw/mem/nvdimm.h | 2 + >> 5 files changed, 252 insertions(+), 1 deletion(-) >> >> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c >> index 95e0c65..c637dc8 100644 >> --- a/hw/i386/acpi-build.c >> +++ b/hw/i386/acpi-build.c >> @@ -1661,6 +1661,7 @@ static bool acpi_has_iommu(void) >> static >> void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) >> { >> + PCMachineState *pcms = PC_MACHINE(qdev_get_machine()); >> GArray *table_offsets; >> unsigned facs, ssdt, dsdt, rsdt; >> AcpiCpuInfo cpu; >> @@ -1742,6 +1743,9 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) >> build_dmar_q35(tables_blob, tables->linker); >> } >> >> + nvdimm_build_acpi_table(&pcms->nvdimm_memory, table_offsets, tables_blob, >> + tables->linker); >> + >> /* Add tables supplied by user (if any) */ >> for (u = acpi_table_first(); u; u = acpi_table_next(u)) { >> unsigned len = acpi_table_len(u); >> diff --git a/hw/mem/nvdimm/acpi.c b/hw/mem/nvdimm/acpi.c >> index b640874..62b1e02 100644 >> --- a/hw/mem/nvdimm/acpi.c >> +++ b/hw/mem/nvdimm/acpi.c >> @@ -32,6 +32,46 @@ >> #include "hw/mem/nvdimm.h" >> #include "internal.h" >> >> +static void nfit_spa_uuid_pm(uuid_le *uuid) >> +{ >> + uuid_le uuid_pm = UUID_LE(0x66f0d379, 0xb4f3, 0x4074, 0xac, 0x43, 0x0d, >> + 0x33, 0x18, 0xb7, 0x8c, 0xdb); >> + memcpy(uuid, &uuid_pm, sizeof(uuid_pm)); >> +} >> + >> +enum { >> + NFIT_STRUCTURE_SPA = 0, >> + NFIT_STRUCTURE_MEMDEV = 1, >> + NFIT_STRUCTURE_IDT = 2, >> + NFIT_STRUCTURE_SMBIOS = 3, >> + NFIT_STRUCTURE_DCR = 4, >> + NFIT_STRUCTURE_BDW = 5, >> + NFIT_STRUCTURE_FLUSH = 6, >> +}; >> + >> +enum { >> + EFI_MEMORY_UC = 0x1ULL, >> + EFI_MEMORY_WC = 0x2ULL, >> + EFI_MEMORY_WT = 0x4ULL, >> + EFI_MEMORY_WB = 0x8ULL, >> + EFI_MEMORY_UCE = 0x10ULL, >> + EFI_MEMORY_WP = 0x1000ULL, >> + EFI_MEMORY_RP = 0x2000ULL, >> + EFI_MEMORY_XP = 0x4000ULL, >> + EFI_MEMORY_NV = 0x8000ULL, >> + EFI_MEMORY_MORE_RELIABLE = 0x10000ULL, >> +}; > > Would it worth including / copying the ACPICA header files directly? > > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/acpi/actbl1.h > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/acpi/acuuid.h Good point, Dan. These files are not exported under uapi/ so that it is not good to directly include it, i will learn the definition and adjust it to QEMU's code style in the next version. Thanks!