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: 7368201 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 77239BEEA4 for ; Sat, 10 Oct 2015 19:59:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0C4C220929 for ; Sat, 10 Oct 2015 19:59:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1B2982091D for ; Sat, 10 Oct 2015 19:59:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752758AbbJJT7h (ORCPT ); Sat, 10 Oct 2015 15:59:37 -0400 Received: from mga03.intel.com ([134.134.136.65]:23517 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752732AbbJJT71 (ORCPT ); Sat, 10 Oct 2015 15:59:27 -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 Cc: gleb@kernel.org, mtosatti@redhat.com, stefanha@redhat.com, mst@redhat.com, rth@twiddle.net, ehabkost@redhat.com, dan.j.williams@intel.com, kvm@vger.kernel.org, qemu-devel@nongnu.org, Xiao Guangrong Subject: [PATCH v3 29/32] nvdimm: support DSM_CMD_GET_NAMESPACE_LABEL_DATA 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, DATE_IN_FUTURE_06_12, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;