From nobody Fri Oct 18 09:16:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; dkim=fail; spf=pass (zoho.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=1569409995; cv=none; d=zoho.com; s=zohoarc; b=nZOGrgIs0MDZi3xNfDxpm9j9yGhvxYiQASOhWyfnQ6RBLNRKzgX95kt1oCS0r27daxX0fruGa0dnXJadcee4na9Som+9K4ocGIP18ZSL7rHdQbdRDQqUnMVpkL7NxFHILHCAqfsrJdSWXkx+Uiyz9TAh33Z9CTrNJ+4boyTyTds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569409995; 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:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=jijw4mo3osb8pd1tKVqFKzKBvaD7tj7dTNiSSh+oews=; b=Z6j7SsyJ9mQMW4GGH8tlV5pWzxg6HSXU0oEHcFPQvQtFF3v20lLsXgviONcVBjVocUiXR9X7Dai0W9gib/dMarI9OYFuqrE9Je8gPtHD8bKLuevdoQ2T6Kamdn1NHvblThwY57aZel4Sg0oABP0Z8+NOnlajf0hjVMg/ULm1LwE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1569409995361550.5269054263241; Wed, 25 Sep 2019 04:13:15 -0700 (PDT) Received: from localhost ([::1]:48224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD5EI-0005r9-9F for importer@patchew.org; Wed, 25 Sep 2019 07:13:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44941) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <3YEqLXQYKChUDv7z3y19916z.x97Bz7F-yzGz689818F.9C1@flex--sameid.bounces.google.com>) id 1iD58m-0000CQ-4x for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <3YEqLXQYKChUDv7z3y19916z.x97Bz7F-yzGz689818F.9C1@flex--sameid.bounces.google.com>) id 1iD58i-0004j3-1a for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:22 -0400 Received: from mail-qt1-x84a.google.com ([2607:f8b0:4864:20::84a]:35830) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <3YEqLXQYKChUDv7z3y19916z.x97Bz7F-yzGz689818F.9C1@flex--sameid.bounces.google.com>) id 1iD58e-0004fD-GZ for qemu-devel@nongnu.org; Wed, 25 Sep 2019 07:07:17 -0400 Received: by mail-qt1-x84a.google.com with SMTP id x25so5496628qtq.2 for ; Wed, 25 Sep 2019 04:07:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=jijw4mo3osb8pd1tKVqFKzKBvaD7tj7dTNiSSh+oews=; b=n0g6EcEhgtLT0NCcAphJmVIq2NP0HJepeKySY5GYfD6hoXKpSIZGzxBUv9bUCAbwB7 PzDQwJgk89Qo2mQC2cgnXps0zF9dySYAXXwq5+8tNUpkYuXRQlNio2NI1UkZzUEcLzJ4 x1Y+8xoOvEdRUi3LJ6EPuo7xAxG5PUjGUua7qqLDq0WZFcobwmgfMu/fdarDPKkEO785 kqJ4XlwPLVQfgX+ScTT+doh1IgMPr6Bmx3e6g1z3pyEoYxUX4g8+qmUcbN2PEXubdwov Sr5hJ9EA4PWrd4wNLnhTA5y57CoqMjwHEwV4K7oN5POnTg8KSEuXyxVeKxkUTiKqStOM Kk+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=jijw4mo3osb8pd1tKVqFKzKBvaD7tj7dTNiSSh+oews=; b=gXeHN43HHRj6hftmdlOQCLJkMwj5avMkoUHkPX4GZu75yV+SXgm2NjZXE4gYhGJ0qk 7mGnMS4G37m10rSZ1d/fgznsmBuNTqq0csA0UZG82NRDD+197BUszGvfo5K3GmwhdiDY /FKPyt2hUxPimAZS3BiAKnYNqEPGFQv0MN9x3BJo7fTkA+M0yIKhLY4qgJbWw4IJ20Pm JdAoT9boi0K8Sa79LBWGhRx3O9WcivSFSj4J7l9M89EMUgYcqZRby9kF+PHf7gNi0Uxa ARsARadKyhGMjAGd/LIoOm53NxiVdmBo2NxlG3atwVHvyXtnw04RJIdU1xNoZF22Uu28 vZfw== X-Gm-Message-State: APjAAAVj1JdVWlBpWcxnOzd5yPJgsxs0cnmMP3ezVbGCSeI8jCBjs004 Mgu8oqPUZQcxWcO07ppvSAlx0V15Ng/sgoC1tnLMhWqwmjNtNK3DIUFtI3whHwdteXWK6zznTl1 XxWYuk9igrBhD9iG7Z3zXb6WyhiIoIIMgDBazYa84Yy+cdTMlkzZ0etABvfhQ X-Google-Smtp-Source: APXvYqw/4BvKzKbIF6sw8qGThdte8SI17nKVQUTMJ49lIMpcHBYNXkbbtZEFy+wcB0/aFY6//UfIkjhUCS0= X-Received: by 2002:a0c:8749:: with SMTP id 9mr6928386qvi.174.1569409632799; Wed, 25 Sep 2019 04:07:12 -0700 (PDT) Date: Wed, 25 Sep 2019 14:06:38 +0300 In-Reply-To: <20190925110639.100699-1-sameid@google.com> Message-Id: <20190925110639.100699-8-sameid@google.com> Mime-Version: 1.0 References: <20190925110639.100699-1-sameid@google.com> X-Mailer: git-send-email 2.23.0.351.gc4317032e6-goog Subject: [PATCH v7 7/8] bootdevice: FW_CFG interface for LCHS values To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::84a 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: kwolf@redhat.com, qemu-block@nongnu.org, arbel.moshe@oracle.com, seabios@seabios.org, kevin@koconnor.net, liran.alon@oracle.com, kraxel@redhat.com, Sam Eiderman , sameid@google.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Sam Eiderman From: Sam Eiderman via X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sam Eiderman Using fw_cfg, supply logical CHS values directly from QEMU to the BIOS. Non-standard logical geometries break under QEMU. A virtual disk which contains an operating system which depends on logical geometries (consistent values being reported from BIOS INT13 AH=3D08) will most likely break under QEMU/SeaBIOS if it has non-standard logical geometries - for example 56 SPT (sectors per track). No matter what QEMU will report - SeaBIOS, for large enough disks - will use LBA translation, which will report 63 SPT instead. In addition we cannot force SeaBIOS to rely on physical geometries at all. A virtio-blk-pci virtual disk with 255 phyiscal heads cannot report more than 16 physical heads when moved to an IDE controller, since the ATA spec allows a maximum of 16 heads - this is an artifact of virtualization. By supplying the logical geometries directly we are able to support such "exotic" disks. We serialize this information in a similar way to the "bootorder" interface. The new fw_cfg entry is "bios-geometry". Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- bootdevice.c | 32 ++++++++++++++++++++++++++++++++ hw/nvram/fw_cfg.c | 14 +++++++++++--- include/sysemu/sysemu.h | 1 + 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/bootdevice.c b/bootdevice.c index 2b12fb85a4..b034ad7bdc 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -405,3 +405,35 @@ void del_boot_device_lchs(DeviceState *dev, const char= *suffix) } } } + +/* Serialized as: (device name\0 + lchs struct) x devices */ +char *get_boot_devices_lchs_list(size_t *size) +{ + FWLCHSEntry *i; + size_t total =3D 0; + char *list =3D NULL; + + QTAILQ_FOREACH(i, &fw_lchs, link) { + char *bootpath; + char *chs_string; + size_t len; + + bootpath =3D get_boot_device_path(i->dev, false, i->suffix); + chs_string =3D g_strdup_printf("%s %" PRIu32 " %" PRIu32 " %" PRIu= 32, + bootpath, i->lcyls, i->lheads, i->lse= cs); + + if (total) { + list[total - 1] =3D '\n'; + } + len =3D strlen(chs_string) + 1; + list =3D g_realloc(list, total + len); + memcpy(&list[total], chs_string, len); + total +=3D len; + g_free(chs_string); + g_free(bootpath); + } + + *size =3D total; + + return list; +} diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 7dc3ac378e..18aff658c0 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -920,13 +920,21 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *f= ilename, =20 static void fw_cfg_machine_reset(void *opaque) { + MachineClass *mc =3D MACHINE_GET_CLASS(qdev_get_machine()); + FWCfgState *s =3D opaque; void *ptr; size_t len; - FWCfgState *s =3D opaque; - char *bootindex =3D get_boot_devices_list(&len); + char *buf; =20 - ptr =3D fw_cfg_modify_file(s, "bootorder", (uint8_t *)bootindex, len); + buf =3D get_boot_devices_list(&len); + ptr =3D fw_cfg_modify_file(s, "bootorder", (uint8_t *)buf, len); g_free(ptr); + + if (!mc->legacy_fw_cfg_order) { + buf =3D get_boot_devices_lchs_list(&len); + ptr =3D fw_cfg_modify_file(s, "bios-geometry", (uint8_t *)buf, len= ); + g_free(ptr); + } } =20 static void fw_cfg_machine_ready(struct Notifier *n, void *data) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 5bc5c79cbc..80c57fdc4e 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -106,6 +106,7 @@ void validate_bootdevices(const char *devices, Error **= errp); void add_boot_device_lchs(DeviceState *dev, const char *suffix, uint32_t lcyls, uint32_t lheads, uint32_t lsecs); void del_boot_device_lchs(DeviceState *dev, const char *suffix); +char *get_boot_devices_lchs_list(size_t *size); =20 /* handler to set the boot_device order for a specific type of MachineClas= s */ typedef void QEMUBootSetHandler(void *opaque, const char *boot_order, --=20 2.23.0.351.gc4317032e6-goog