From nobody Mon Sep 16 19:11:18 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1560332650; cv=none; d=zoho.com; s=zohoarc; b=U2aKw18oPE9wzHl0DoY+JFBJzOTg1KEoNYqU2bfIYr3qYGvt3+oyQJwH5onOnI/TPUshApURIFSZ33ulCmXgiW331lrmF3rY8kX1Milz/J5Rp3SWDC4kh+Tcf/Vf5gxHYcWWRCb3hIUBfqNe5FfAVH82glkTJOKbRd6zYjkcwTw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560332650; h=Content-Type: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:Subject:To:ARC-Authentication-Results; bh=3b14QT89owHoZyMeFkJS6tvE4UYGOTmOP58+ZTsWPc0=; b=NGwtvLCT/vFwyKmdemxpBVJ8Lm/IKT+o0d5CQNpb4wcGsdWGeMgLQIpq+F6i2Yca0exU7QTEXUXd3P2/omZJun6/ebxzIjGNdArKNIp4qFz9qNtXiC7xf9wl6sQEzi/v4RdIVGlE6OxLoCstO0cEOI0OgxFAjEgELkID6bdDtzk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 156033265097216.568496809353405; Wed, 12 Jun 2019 02:44:10 -0700 (PDT) Received: from [192.168.203.99] (mailu_mailman-core_1.mailu_default [192.168.203.99]) by coreboot.org (Postfix) with ESMTP id BF47912E2EE2; Wed, 12 Jun 2019 09:44:06 +0000 (UTC) Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by coreboot.org (Postfix) with ESMTP id 00F4112E2EC4 for ; Wed, 12 Jun 2019 09:43:46 +0000 (UTC) Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C9XjWb185066; Wed, 12 Jun 2019 09:43:25 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2t04ettc2d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Jun 2019 09:43:24 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5C9gTvx116550; Wed, 12 Jun 2019 09:43:24 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2t0p9rsgqx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Jun 2019 09:43:23 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5C9hNjG018497; Wed, 12 Jun 2019 09:43:23 GMT Received: from nexus.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 12 Jun 2019 02:43:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=hQZ3WEyRXWZ6Vma864cBiiSbs9o8TGD6e7LS+aGjIko=; b=QkpLScKZ5vFO7WxRrAlJiOvVhMt8v1GXxtvzWWllgMQldzUvunW5wUeVql+yIAdl6k6R PpL32FBrECndZ+trGAsNQDaBe+umEeFqPPxrGw+UrUfKRE/TG6DfZNy1Hdl2O9gwBNrT 0sekQmU3kkByd6XYQa5h930Xdr7LfoiK/447Vm/jkZF3mKTuXxwHG+u4BfMuCzJLx+iE kr1G90TSUus5O+0IZX45onKvkuk60r1FKHYwYupmOxi0cwuNZ/MmyYSOW4fCwb+WRf6e 46hosR4H2hFBiW5frG+JstZ2didf3J1w/oxyx5ZhXYgZ9hWOoapXG4/dz8zyqgHxVApR mA== From: Sam Eiderman To: kwolf@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com, seabios@seabios.org, kraxel@redhat.com, kevin@koconnor.net Date: Wed, 12 Jun 2019 12:42:36 +0300 Message-Id: <20190612094237.47462-8-shmuel.eiderman@oracle.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20190612094237.47462-1-shmuel.eiderman@oracle.com> References: <20190612094237.47462-1-shmuel.eiderman@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120067 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9285 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906120066 Message-ID-Hash: XTO7SE63WF5YYCIGWYKWTTGZ2ZQNOPC6 X-Message-ID-Hash: XTO7SE63WF5YYCIGWYKWTTGZ2ZQNOPC6 X-MailFrom: shmuel.eiderman@oracle.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: karl.heubaum@oracle.com, arbel.moshe@oracle.com X-Mailman-Version: 3.2.2 Precedence: list Subject: [SeaBIOS] [QEMU] [PATCH 7/8] bootdevice: FW_CFG interface for LCHS values List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org X-Spamd-Bar: / X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 fw_cfg entry is "bootdevices" and it serializes a struct. At the moment the struct holds the values of logical CHS values but it can be expanded easily due to the extendable ABI implemented. (In the future, we can pass the bootindex through "bootdevices" instead "bootorder" - unifying all bootdevice information in one fw_cfg value) The PV interface through fw_cfg could have also been implemented using device specific keys, e.g.: "/etc/bootdevice/%s/logical_geometry" where %s is the device name QEMU produces - but this implementation would require much more code refactoring, both in QEMU and SeaBIOS, so the current implementation was chosen. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman --- bootdevice.c | 42 ++++++++++++++++++++++++++++++++++++++++++ hw/nvram/fw_cfg.c | 14 +++++++++++--- include/sysemu/sysemu.h | 1 + 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/bootdevice.c b/bootdevice.c index 2b12fb85a4..84c2a83f25 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -405,3 +405,45 @@ void del_boot_device_lchs(DeviceState *dev, const char= *suffix) } } } + +typedef struct QEMU_PACKED BootDeviceEntrySerialized { + /* Do not change field order - add new fields below */ + uint32_t lcyls; + uint32_t lheads; + uint32_t lsecs; +} BootDeviceEntrySerialized; + +/* Serialized as: struct size (4) + (device name\0 + device struct) x devi= ces */ +char *get_boot_devices_info(size_t *size) +{ + FWLCHSEntry *i; + BootDeviceEntrySerialized s; + size_t total =3D 0; + char *list =3D NULL; + + list =3D g_malloc0(sizeof(uint32_t)); + *((uint32_t *)list) =3D (uint32_t)sizeof(s); + total =3D sizeof(uint32_t); + + QTAILQ_FOREACH(i, &fw_lchs, link) { + char *bootpath; + size_t len; + + bootpath =3D get_boot_device_path(i->dev, false, i->suffix); + s.lcyls =3D i->lcyls; + s.lheads =3D i->lheads; + s.lsecs =3D i->lsecs; + + len =3D strlen(bootpath) + 1; + list =3D g_realloc(list, total + len + sizeof(s)); + memcpy(&list[total], bootpath, len); + memcpy(&list[total + len], &s, sizeof(s)); + total +=3D len + sizeof(s); + + g_free(bootpath); + } + + *size =3D total; + + return list; +} diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 9f7b7789bc..008b21542f 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -916,13 +916,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_info(&len); + ptr =3D fw_cfg_modify_file(s, "bootdevices", (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 173dfbb539..f0552006f4 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -174,6 +174,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_info(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.13.3 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org