From patchwork Sun Oct 11 03:53:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 528681 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A0F101400A0 for ; Sun, 11 Oct 2015 07:16:49 +1100 (AEDT) Received: from localhost ([::1]:46223 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zl0ZT-0004S2-Op for incoming@patchwork.ozlabs.org; Sat, 10 Oct 2015 16:16:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zl0Ik-0001e1-81 for qemu-devel@nongnu.org; Sat, 10 Oct 2015 15:59:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zl0Ig-00044U-5k for qemu-devel@nongnu.org; Sat, 10 Oct 2015 15:59:30 -0400 Received: from mga03.intel.com ([134.134.136.65]:60642) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zl0Ig-0003bu-0v for qemu-devel@nongnu.org; Sat, 10 Oct 2015 15:59:26 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 10 Oct 2015 12:59:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,664,1437462000"; d="scan'208";a="661783235" Received: from xiaoreal1.sh.intel.com (HELO xiaoreal1.sh.intel.com.sh.intel.com) ([10.239.48.79]) by orsmga003.jf.intel.com with ESMTP; 10 Oct 2015 12:59:23 -0700 From: Xiao Guangrong To: pbonzini@redhat.com, imammedo@redhat.com Date: Sun, 11 Oct 2015 11:53:01 +0800 Message-Id: <1444535584-18220-30-git-send-email-guangrong.xiao@linux.intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1444535584-18220-1-git-send-email-guangrong.xiao@linux.intel.com> References: <1444535584-18220-1-git-send-email-guangrong.xiao@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.65 Cc: Xiao Guangrong , ehabkost@redhat.com, kvm@vger.kernel.org, mst@redhat.com, gleb@kernel.org, mtosatti@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, dan.j.williams@intel.com, rth@twiddle.net Subject: [Qemu-devel] [PATCH v3 29/32] nvdimm: support DSM_CMD_GET_NAMESPACE_LABEL_DATA X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Function 5 is used to get Namespace Label Data Signed-off-by: Xiao Guangrong --- hw/mem/nvdimm/acpi.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/hw/mem/nvdimm/acpi.c b/hw/mem/nvdimm/acpi.c index b420e2f..e0a37cb 100644 --- a/hw/mem/nvdimm/acpi.c +++ b/hw/mem/nvdimm/acpi.c @@ -401,6 +401,7 @@ struct dsm_in { union { uint8_t arg3[0]; cmd_in_set_label_data cmd_set_label_data; + cmd_in_get_label_data cmd_get_label_data; }; } QEMU_PACKED; typedef struct dsm_in dsm_in; @@ -504,6 +505,35 @@ dsm_cmd_label_size(MemoryRegion *dsm_ram_mr, NVDIMMDevice *nvdimm, return DSM_STATUS_SUCCESS; } +static uint32_t dsm_cmd_get_label_data(NVDIMMDevice *nvdimm, dsm_in *in, + dsm_out *out) +{ + cmd_in_get_label_data *cmd_in = &in->cmd_get_label_data; + uint32_t length, offset, status; + + length = cmd_in->length; + offset = cmd_in->offset; + le32_to_cpus(&length); + le32_to_cpus(&offset); + + nvdebug("Read Label Data: offset %#x length %#x.\n", offset, length); + + if (nvdimm->label_size < length + offset) { + nvdebug("position %#x is beyond label data (len = %#lx).\n", + length + offset, nvdimm->label_size); + out->len = sizeof(out->status); + status = DSM_STATUS_INVALID_PARAS; + goto exit; + } + + status = DSM_STATUS_SUCCESS; + memcpy(out->cmd_get_label_data.out_buf, nvdimm->label_data + + offset, length); + out->len = sizeof(out->cmd_get_label_data) + length; +exit: + return status; +} + static void dsm_write_nvdimm(MemoryRegion *dsm_ram_mr, uint32_t handle, uint32_t function, dsm_in *in, dsm_out *out) { @@ -526,6 +556,9 @@ static void dsm_write_nvdimm(MemoryRegion *dsm_ram_mr, uint32_t handle, case DSM_CMD_NAMESPACE_LABEL_SIZE: status = dsm_cmd_label_size(dsm_ram_mr, nvdimm, out); break; + case DSM_CMD_GET_NAMESPACE_LABEL_DATA: + status = dsm_cmd_get_label_data(nvdimm, in, out); + break; default: out->len = sizeof(out->status); status = DSM_STATUS_NOT_SUPPORTED;