From nobody Sat May 18 23:23:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1598392770; cv=none; d=zohomail.com; s=zohoarc; b=EdVjZBK6fIEqu6gUrIE8R+uOcu8v9yzF+f4PRs5nU1fexsufNtgYlsL1Qpd5WrLCDKnqWHTDXcva9TtZrrnvyf/4RYKOkXMXBl+2kdbbchZT4YN7V3IygP03yL4aDSnHG9QsNIgIOhikIq/SIo2RmUxF04Mxfp1nByh8m0kJS68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598392770; h=Content-Transfer-Encoding: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=BxaXqcaJ3YwDhwzhxTIh6QGfPMHlC2aIVJsVz9sdbO8=; b=YiZX47dP2z3Cds1fkM59Yk0JMtuOOVUSEQtCNdVgEHqQtlk+iXK6AKnDDDgonL0077u+16GBrrpWm6AbImWxlhVijnsIRT95P3uh0N3qEUp7dCXx5X0+Uz0UKQBe1MMoKo3dRdf4HIFqYDbH1TCyGJb7+t8wAhkW4aN0MxBDaCo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598392770938462.8393943263791; Tue, 25 Aug 2020 14:59:30 -0700 (PDT) Received: from localhost ([::1]:33728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kAgyU-0005JI-Lo for importer@patchew.org; Tue, 25 Aug 2020 17:59:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48244) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAgxA-0002Mt-MU; Tue, 25 Aug 2020 17:58:04 -0400 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]:41522) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kAgx7-0000Xv-Kp; Tue, 25 Aug 2020 17:58:04 -0400 Received: by mail-qt1-x841.google.com with SMTP id t20so12959qtr.8; Tue, 25 Aug 2020 14:58:00 -0700 (PDT) Received: from localhost.localdomain ([2804:431:c7c7:c152:8180:e1dd:d6ac:1152]) by smtp.gmail.com with ESMTPSA id z2sm347362qtu.11.2020.08.25.14.57.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 14:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BxaXqcaJ3YwDhwzhxTIh6QGfPMHlC2aIVJsVz9sdbO8=; b=FpGSKVI3qXQ3oio0PJag6nDdy1m8OdH64jqMd0u+rXAuaPqHWjM3ONKUfL9eqN1mHJ zaQEsqq6SxPq2pRhqBzlxGL8MjU6toiWzyM5HmzzEOUymbWYdV7/4CtKtlrFJ2ZFdzdH 5aemhdhwJb9EuJHpvic9qeYcmr9igiWR7bjOZROQiaYgdR4NgyD21j45Uj/QMUxbJPg0 NQSjpqKYnN6uUFch6vENzWFPn88PhzICRV/dMH0V4rrnfJN49/g39Ca5bl03THu3Pm4k sL6gokH5Vvd19ZLxjt2lMitkbMP4muRZaOB7eQ0arrr6kk7gHWHJc4LlWyZLAlNXu64u 9SqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BxaXqcaJ3YwDhwzhxTIh6QGfPMHlC2aIVJsVz9sdbO8=; b=KrOZlaywhc3pUlWVszXAUSoVMs1/rnp2r26RdfLmJJpLUHy4DTFaIhRgqbf1th+05s lVcrxXMSDtDoTaohlYJTzhkSXNWiG9RoMwTyJuXwgZIyyNhIkBrfQpoSxg25tvVKEOdD sM60R9wB4BsafLWTrGEqbnI+jkk9X9rOPjEchfb+dmlY2mV5P+ZhkjjQ3cnkDaDuhtx6 KkDFaCeYXboFd/Ho71nxca5dfjhfL5Nv6bBBpsMzbSuU13Bhth2NfUVca02iAvxG41Yy Bl9y2HdOEwdnVBk7SmHdojxXm/kY8FWjOmrZBJIqQxfh2erysYUhZCoeB6yi3ZB3UDOl 5Wmw== X-Gm-Message-State: AOAM5336ytvMd+TuA579kK5ukiT4TiYcwiNl9VNEBEfdbDmR9A4ykNMe Mi6agvH2hU98KCa5DsBoEgQc8P2oLhM= X-Google-Smtp-Source: ABdhPJzaNslfl68zZXHGcHUJ+d7FEbEbJpB1blKIp2UHAAYJCZucFtMtMe+baUyA0xIViVAUemIZoA== X-Received: by 2002:ac8:1488:: with SMTP id l8mr11429791qtj.131.1598392680184; Tue, 25 Aug 2020 14:58:00 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 1/3] ppc/spapr_nvdimm: use g_autofree in spapr_nvdimm_validate_opts() Date: Tue, 25 Aug 2020 18:57:47 -0300 Message-Id: <20200825215749.213536-2-danielhb413@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200825215749.213536-1-danielhb413@gmail.com> References: <20200825215749.213536-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2607:f8b0:4864:20::841; envelope-from=danielhb413@gmail.com; helo=mail-qt1-x841.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Daniel Henrique Barboza , qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Since we're using the string just once, just use g_autofree and avoid leaking it without calling g_free(). Signed-off-by: Daniel Henrique Barboza --- hw/ppc/spapr_nvdimm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/ppc/spapr_nvdimm.c b/hw/ppc/spapr_nvdimm.c index 81410aa63f..9a20a65640 100644 --- a/hw/ppc/spapr_nvdimm.c +++ b/hw/ppc/spapr_nvdimm.c @@ -33,7 +33,7 @@ void spapr_nvdimm_validate_opts(NVDIMMDevice *nvdimm, uint64_t size, Error **errp) { - char *uuidstr =3D NULL; + g_autofree char *uuidstr =3D NULL; QemuUUID uuid; int ret; =20 @@ -54,7 +54,6 @@ void spapr_nvdimm_validate_opts(NVDIMMDevice *nvdimm, uin= t64_t size, &error_abort); ret =3D qemu_uuid_parse(uuidstr, &uuid); g_assert(!ret); - g_free(uuidstr); =20 if (qemu_uuid_is_null(&uuid)) { error_setg(errp, "NVDIMM device requires the uuid to be set"); --=20 2.26.2 From nobody Sat May 18 23:23:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1598392824; cv=none; d=zohomail.com; s=zohoarc; b=X9zXhJH535xET9g0jLztl3mVPTdNTeH9G9uBtyx1BLdSxPBpB99ucQe9IiparFMlj+kYpVBuYxv9sqfaqGqUF/vacxf/zXDFSm4LTXA/nITNb5TwO8QRuPNsASz1mTHYbhM3LK9CfCPcGAMko3LdejrBaK/GMM0EJJxrSkRJeVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598392824; h=Content-Transfer-Encoding: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=gs8bi7VVxJby/VCGELptjbix2K07oxRPUhMrOOcTGBw=; b=RopawSldLMQAYOTkcIdtLFHumwsstXVGowWbcx5Nv4lTUghKU+wnKTv9Yx7ZPooW9Tasb1bFT2AaHUqtEIzN+SeAubiINrX66O6QP+sgyYa/iRJLKptOirpo6K/8bkcDuqn6srkkHm2CQnIw1byYzWCAzwRiwHQnzytkJA9sDeI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598392824895602.8221388114592; Tue, 25 Aug 2020 15:00:24 -0700 (PDT) Received: from localhost ([::1]:36874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kAgzP-0006aj-Lw for importer@patchew.org; Tue, 25 Aug 2020 18:00:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAgxC-0002R6-6F; Tue, 25 Aug 2020 17:58:06 -0400 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]:45587) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kAgx9-0000YB-Io; Tue, 25 Aug 2020 17:58:05 -0400 Received: by mail-qt1-x842.google.com with SMTP id p36so167858qtd.12; Tue, 25 Aug 2020 14:58:02 -0700 (PDT) Received: from localhost.localdomain ([2804:431:c7c7:c152:8180:e1dd:d6ac:1152]) by smtp.gmail.com with ESMTPSA id z2sm347362qtu.11.2020.08.25.14.58.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 14:58:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gs8bi7VVxJby/VCGELptjbix2K07oxRPUhMrOOcTGBw=; b=AU0C6GRYJ0zM/9ZjjxtQHS+ejltWYnm05WyAAImVBcWogxMEf3DRSTxluvKsVrCwQW U19ge4DqspNMKIRlxidf9dOTf5wl89dAJKeaEXERsoDhFSvqOyjgY03blwuIp/qqSkc9 PhyStZWw99dzpL9FBxYEigTUsWq3dgxkO6ZNb9KoHQ9WpBUJ2LY3Z9joXoNMpsAEUVno yEQw+IFqxLg9u+D8GgEjAVhzShayossUCjpD9aoB+Tlc758WYtcb/YY2ECgtoTrfdzfK fyJyvCtqjd+/I8OaqqxfqGPKDf1uBpeg4aRI9kHeHGJG5Cg1GWtcDLFQ711kFmOYdewz /9gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gs8bi7VVxJby/VCGELptjbix2K07oxRPUhMrOOcTGBw=; b=s1WJqtbTSWoqWpWfMWlnlpp2WspV1S6UZH/qQXJkg6i/AhtdOqh47qKJQtU1yz/44Y EYpi6nelPZZ23JX73jRpujSY2Q6MQSS403gzjTP/flWR5BUKenxuTsLQUFWgk5s1Ykjc WnDTiWWG4LoAKY8xbGodhAv7zg/ImCfEbEfptlsNqTUAkoF3xYLHODvSSEng4GOX6Sg9 DHWKvDh3t6rpnQ/ACGXvDud3Epn7WU3AzW0taSubLpZMmAiQ8Cpyr9PhDzFHOPMm69to KeA8O7urVZYMJPNJkPm4KiKIkj4rsplqDijB4/XPKndtg9Am3KoWFgpdm9OFSY/3TD8+ PFwQ== X-Gm-Message-State: AOAM530+juVD7XXiVAT1u3M5fPzQcPHevk4O/YVskIOqRrf6u5V2TQ1v pstkrvqN73UaQgj7WZarvCPWQiipEDk= X-Google-Smtp-Source: ABdhPJxGi34TpnofDEwH6Hzd+uzM9jsVaiIZM9wELTcDyc+3e1I6tPx5TeUJBAwLKwkW/eyrPK2QIg== X-Received: by 2002:ac8:4b52:: with SMTP id e18mr11432826qts.231.1598392682160; Tue, 25 Aug 2020 14:58:02 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 2/3] spapr, spapr_nvdimm: fold NVDIMM validation in the same place Date: Tue, 25 Aug 2020 18:57:48 -0300 Message-Id: <20200825215749.213536-3-danielhb413@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200825215749.213536-1-danielhb413@gmail.com> References: <20200825215749.213536-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2607:f8b0:4864:20::842; envelope-from=danielhb413@gmail.com; helo=mail-qt1-x842.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Daniel Henrique Barboza , qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" NVDIMM has different contraints and conditions than the regular DIMM and we'll need to add at least one more. Instead of relying on 'if (nvdimm)' conditionals in the body of spapr_memory_pre_plug(), use the existing spapr_nvdimm_validate_opts() and put all NVDIMM handling code there. Rename it to spapr_nvdimm_validate() to reflect that the function is now checking more than the nvdimm device options. This makes spapr_memory_pre_plug() a bit easier to follow, and we can tune in NVDIMM parameters and validation in the same place. Signed-off-by: Daniel Henrique Barboza --- hw/ppc/spapr.c | 18 ++++++------------ hw/ppc/spapr_nvdimm.c | 10 ++++++++-- include/hw/ppc/spapr_nvdimm.h | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index dd2fa4826b..b0a04443fb 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3520,7 +3520,6 @@ static void spapr_memory_pre_plug(HotplugHandler *hot= plug_dev, DeviceState *dev, { const SpaprMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(hotplug_dev); SpaprMachineState *spapr =3D SPAPR_MACHINE(hotplug_dev); - const MachineClass *mc =3D MACHINE_CLASS(smc); bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); PCDIMMDevice *dimm =3D PC_DIMM(dev); Error *local_err =3D NULL; @@ -3533,27 +3532,22 @@ static void spapr_memory_pre_plug(HotplugHandler *h= otplug_dev, DeviceState *dev, return; } =20 - if (is_nvdimm && !mc->nvdimm_supported) { - error_setg(errp, "NVDIMM hotplug not supported for this machine"); - return; - } - size =3D memory_device_get_region_size(MEMORY_DEVICE(dimm), &local_err= ); if (local_err) { error_propagate(errp, local_err); return; } =20 - if (!is_nvdimm && size % SPAPR_MEMORY_BLOCK_SIZE) { - error_setg(errp, "Hotplugged memory size must be a multiple of " - "%" PRIu64 " MB", SPAPR_MEMORY_BLOCK_SIZE / MiB); - return; - } else if (is_nvdimm) { - spapr_nvdimm_validate_opts(NVDIMM(dev), size, &local_err); + if (is_nvdimm) { + spapr_nvdimm_validate(hotplug_dev, NVDIMM(dev), size, &local_err); if (local_err) { error_propagate(errp, local_err); return; } + } else if (size % SPAPR_MEMORY_BLOCK_SIZE) { + error_setg(errp, "Hotplugged memory size must be a multiple of " + "%" PRIu64 " MB", SPAPR_MEMORY_BLOCK_SIZE / MiB); + return; } =20 memdev =3D object_property_get_link(OBJECT(dimm), PC_DIMM_MEMDEV_PROP, diff --git a/hw/ppc/spapr_nvdimm.c b/hw/ppc/spapr_nvdimm.c index 9a20a65640..bc2b65420c 100644 --- a/hw/ppc/spapr_nvdimm.c +++ b/hw/ppc/spapr_nvdimm.c @@ -30,13 +30,19 @@ #include "hw/ppc/fdt.h" #include "qemu/range.h" =20 -void spapr_nvdimm_validate_opts(NVDIMMDevice *nvdimm, uint64_t size, - Error **errp) +void spapr_nvdimm_validate(HotplugHandler *hotplug_dev, NVDIMMDevice *nvdi= mm, + uint64_t size, Error **errp) { + const MachineClass *mc =3D MACHINE_GET_CLASS(hotplug_dev); g_autofree char *uuidstr =3D NULL; QemuUUID uuid; int ret; =20 + if (!mc->nvdimm_supported) { + error_setg(errp, "NVDIMM hotplug not supported for this machine"); + return; + } + if (object_property_get_int(OBJECT(nvdimm), NVDIMM_LABEL_SIZE_PROP, &error_abort) =3D=3D 0) { error_setg(errp, "PAPR requires NVDIMM devices to have label-size = set"); diff --git a/include/hw/ppc/spapr_nvdimm.h b/include/hw/ppc/spapr_nvdimm.h index b3330cc485..fd1736634c 100644 --- a/include/hw/ppc/spapr_nvdimm.h +++ b/include/hw/ppc/spapr_nvdimm.h @@ -29,8 +29,8 @@ int spapr_pmem_dt_populate(SpaprDrc *drc, SpaprMachineSta= te *spapr, void *fdt, int *fdt_start_offset, Error **errp); int spapr_dt_nvdimm(void *fdt, int parent_offset, NVDIMMDevice *nvdimm); void spapr_dt_persistent_memory(void *fdt); -void spapr_nvdimm_validate_opts(NVDIMMDevice *nvdimm, uint64_t size, - Error **errp); +void spapr_nvdimm_validate(HotplugHandler *hotplug_dev, NVDIMMDevice *nvdi= mm, + uint64_t size, Error **errp); void spapr_add_nvdimm(DeviceState *dev, uint64_t slot, Error **errp); void spapr_create_nvdimm_dr_connectors(SpaprMachineState *spapr); =20 --=20 2.26.2 From nobody Sat May 18 23:23:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1598392902; cv=none; d=zohomail.com; s=zohoarc; b=jBHYnpQ3bNTB9AID0rw1cSRPhNAePvRy/RlTGAEAJQ8G1w3iZ3MaKTE+aGrFcvvuK9hXeCJDKzoKHXw5kwZ/L+4T2kAj7xrgENC19UGciZYqRwMyQRtqvKGW49geZpbRp/m82PeB9I+MaJCp3S87/fTB5WjIvcvS6B0whg0Q4NI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598392902; h=Content-Transfer-Encoding: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=mJdoucNwI/OnnzvaQh846qvbJjNp6NDdrYfpoZKb5zI=; b=KPTBkkLXXW4tIzdWyiqm9XOWA0kNJu+fXAj5wO+jB0fUojCIC1P1nu1xLi5tDvKaCgxpZoSdxQ1CcpfuTGb/Luzq8SLI6ZBk+CWlK/PG9so3bSqma29BSB0hc2bhrGNg/iThuv7vIJyWlZW7HTXrUyu9zIX03UpkP7rISsut+xc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598392902931395.92151191396465; Tue, 25 Aug 2020 15:01:42 -0700 (PDT) Received: from localhost ([::1]:39390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kAh0f-0007kF-FJ for importer@patchew.org; Tue, 25 Aug 2020 18:01:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAgxD-0002Vb-MT; Tue, 25 Aug 2020 17:58:07 -0400 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]:45587) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kAgxB-0000YX-IE; Tue, 25 Aug 2020 17:58:07 -0400 Received: by mail-qt1-x841.google.com with SMTP id p36so167933qtd.12; Tue, 25 Aug 2020 14:58:04 -0700 (PDT) Received: from localhost.localdomain ([2804:431:c7c7:c152:8180:e1dd:d6ac:1152]) by smtp.gmail.com with ESMTPSA id z2sm347362qtu.11.2020.08.25.14.58.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 14:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mJdoucNwI/OnnzvaQh846qvbJjNp6NDdrYfpoZKb5zI=; b=vDyI43j5QW2UHrMiUy7YS9k2xNQOUqKX6n7RPidjjbeazTgiqc/qiyV14x5rUn9BTL 4hhXEh1CwCsDlL1w36+xFACFpPkJNTrYa/GXMt1CJ2xilOibeOIrvHQoMjqLug+jzDBq iiee6hFUc/1zD0IYNHvabltOfVb2AUXZbLZDZoIxTYGurnQVyS+hzuGgHN3mZK24/p+Q tZgckjbN4FWuiPbR/+BiwA6gvx3T4oSXkl7nBEOMzEr0J1RCQq8nwPUUZ73n9PfxiS4k H0Mbf9f9U7+yZ5S0Hq+BGCz1A0wQDupjMDU1YTU/FynLsgph9W/I+7VruD/H+/YEHi5E rFMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mJdoucNwI/OnnzvaQh846qvbJjNp6NDdrYfpoZKb5zI=; b=DPr1KNneLb0YYR2n4a+fExrEWeHdUA3FJIq+V6oOnjg0WVmgpE1U+kAq4LvVFoNmN1 znDWxARw/xDNtW3bi44bLIcNiRiXd/J2vcfVZMnY7BwJ8iOmiJOkPbCoDRWNXDAJN9ac I533mYYPjSu2bel+3sJfek8TSH7Z4+duCJMbN4QG+BjFQNfUkenSkvJlwunG3X28XgZK Rva6K1pn00WD65HYU4hmMpyluCiDgZIZI4HQ2pkMb2vQ6klpzcuOvsAc6ZrfafgVQ56P SI2I0npD2o7zaIsYA1d0R2+zyxBDnc6OQP9tMoGnxPI0SsKEL0zZzmw9ZOsIwRvy1owI vT8g== X-Gm-Message-State: AOAM533FKX6/wxPwwJGdhfAeKOidibwYryccZAsZjO6hM23bCVBbpUPD YpkACisV1gbm9jAex8Z4Wr7X+hvZp8k= X-Google-Smtp-Source: ABdhPJwwZtulvPRufcinJMi0gBKmPVJIhjvTIVGNRlAJSy1vmIYZWQEQXbWEBDYZRL39zh0mTguyOg== X-Received: by 2002:ac8:4b78:: with SMTP id g24mr11532474qts.248.1598392684073; Tue, 25 Aug 2020 14:58:04 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 3/3] ppc/spapr_nvdimm: do not enable support with 'nvdimm=off' Date: Tue, 25 Aug 2020 18:57:49 -0300 Message-Id: <20200825215749.213536-4-danielhb413@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200825215749.213536-1-danielhb413@gmail.com> References: <20200825215749.213536-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2607:f8b0:4864:20::841; envelope-from=danielhb413@gmail.com; helo=mail-qt1-x841.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Daniel Henrique Barboza , qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The NVDIMM support for pSeries was introduced in 5.1, but it didn't contemplate the 'nvdimm' machine option that other archs uses. For every other arch, if no '-machine nvdimm(=3Don)' is present, it is assumed that the NVDIMM support is disabled. The user must explictly inform that the machine supports NVDIMM. For pseries-5.1 the 'nvdimm' option is completely ignored, and support is always assumed to exist. This leads to situations where the user is able to set 'nvdimm=3Doff' but the guest boots up with the NVDIMMs anyway. Fixing this now, after 5.1 launch, can put the overall NVDIMM support for pseries in a strange place regarding this 'nvdimm' machine option. If we force everything to be like other archs, existing pseries-5.1 guests that didn't use 'nvdimm' to use NVDIMM devices will break. If we attempt to make the newer pseries machines (5.2+) behave like everyone else, but keep pseries-5.1 untouched, we'll have consistency problems on machine upgrade (5.1 will have different default values for NVDIMM support than 5.2). The common ground here is, if the user sets 'nvdimm=3Doff', we must comply regardless of being 5.1 or 5.2+. This patch changes spapr_nvdimm_validate() to verify if the user set NVDIMM support off in the machine options and, in that case, error out if we have a NVDIMM device. The default value for 5.2+ pseries machines will still be 'nvdimm=3Don' when there is no 'nvdimm' option declared, just like it is today with pseries-5.1. In the end we'll have different default semantics from everyone else in the absence of the 'nvdimm' machine option, but this boat has sailed. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D1848887 Signed-off-by: Daniel Henrique Barboza --- hw/ppc/spapr_nvdimm.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hw/ppc/spapr_nvdimm.c b/hw/ppc/spapr_nvdimm.c index bc2b65420c..95cbc30528 100644 --- a/hw/ppc/spapr_nvdimm.c +++ b/hw/ppc/spapr_nvdimm.c @@ -27,13 +27,17 @@ #include "hw/ppc/spapr_nvdimm.h" #include "hw/mem/nvdimm.h" #include "qemu/nvdimm-utils.h" +#include "qemu/option.h" #include "hw/ppc/fdt.h" #include "qemu/range.h" +#include "sysemu/sysemu.h" =20 void spapr_nvdimm_validate(HotplugHandler *hotplug_dev, NVDIMMDevice *nvdi= mm, uint64_t size, Error **errp) { const MachineClass *mc =3D MACHINE_GET_CLASS(hotplug_dev); + const MachineState *ms =3D MACHINE(hotplug_dev); + const char *nvdimm_opt =3D qemu_opt_get(qemu_get_machine_opts(), "nvdi= mm"); g_autofree char *uuidstr =3D NULL; QemuUUID uuid; int ret; @@ -43,6 +47,20 @@ void spapr_nvdimm_validate(HotplugHandler *hotplug_dev, = NVDIMMDevice *nvdimm, return; } =20 + /* + * NVDIMM support went live in 5.1 without considering that, in + * other archs, the user needs to enable NVDIMM support with the + * 'nvdimm' machine option and the default behavior is NVDIMM + * support disabled. It is too late to roll back to the standard + * behavior without breaking 5.1 guests. What we can do is to + * ensure that, if the user sets nvdimm=3Doff, we error out + * regardless of being 5.1 or newer. + */ + if (!ms->nvdimms_state->is_enabled && nvdimm_opt) { + error_setg(errp, "nvdimm device found but 'nvdimm=3Doff' was set"); + return; + } + if (object_property_get_int(OBJECT(nvdimm), NVDIMM_LABEL_SIZE_PROP, &error_abort) =3D=3D 0) { error_setg(errp, "PAPR requires NVDIMM devices to have label-size = set"); --=20 2.26.2