From nobody Mon Feb 9 00:19:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1641470409; cv=none; d=zohomail.com; s=zohoarc; b=P2h+xQ4vEunFNYzC/vf4zZ9MOaEUpF4jtQQK8TB2QVAev4s2X7YveEZvk3L2nZhfb4dtOMPjaCUazhe/feR/e6iqHwaCCwhjwA5dDxFJy1kUWZKcCg8jwNjRbjmxywqotkZDkNlgPVV+f3PQgqSGIC0YY3Jm2Dw3sDyueS59le8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641470409; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l6pifbgOadZ0E6Wgy90T2ZIm93BZS6I+9qz60NhwbHg=; b=nqIZT7dkqbJlL8In+y4BAHK1/m9xcGQ+NqGI10i3usHbnNTwuf1F8fE0uIM4t0CWjusRr4iVneOL3UZtmQ6mYOVTnXnn9M9nGakrk74Bvb2wKvOuiIVKDxRAPtiQP3Hg6+uLlBQAGKt7+Ab8BaB51enQf+EuuGMpFfA85vlaaTU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1641470409326499.7235821997425; Thu, 6 Jan 2022 04:00:09 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.253948.435385 (Exim 4.92) (envelope-from ) id 1n5RQq-0004QY-D0; Thu, 06 Jan 2022 11:59:48 +0000 Received: by outflank-mailman (output) from mailman id 253948.435385; Thu, 06 Jan 2022 11:59:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RQq-0004QR-8c; Thu, 06 Jan 2022 11:59:48 +0000 Received: by outflank-mailman (input) for mailman id 253948; Thu, 06 Jan 2022 11:59:46 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RPE-0005UX-Ua for xen-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:09 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e27cd5ea-6ee7-11ec-81c0-a30af7de8005; Thu, 06 Jan 2022 12:57:57 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 97BA6212C9; Thu, 6 Jan 2022 11:57:55 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6E1E113C0D; Thu, 6 Jan 2022 11:57:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 4EmeGUPZ1mHnJgAAMHmgww (envelope-from ); Thu, 06 Jan 2022 11:57:55 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: e27cd5ea-6ee7-11ec-81c0-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641470275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l6pifbgOadZ0E6Wgy90T2ZIm93BZS6I+9qz60NhwbHg=; b=he6FNPlM2m97aBvtYpvwfEY0RsYBMXKDCpgoUo/1sc9lUS1Jw7v153yVQr67iV30WlYYwb TOWWwtkX7hmthBY/Niu1bCvj74zvAk3lH5igNigLiWvhPtLizCsIjUHaznFBukOVdS5m++ NZc6V59v90ZABblqWZQdsO9TPuHm/Zc= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, wl@xen.org, Juergen Gross Subject: [PATCH 02/15] mini-os: makes file.read bool and move it ahead of device specific part Date: Thu, 6 Jan 2022 12:57:28 +0100 Message-Id: <20220106115741.3219-3-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220106115741.3219-1-jgross@suse.com> References: <20220106115741.3219-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641470411767100001 Content-Type: text/plain; charset="utf-8" The read member of struct file should be bool. In order to have the device specific part at the end of the structure move "read" ahead of that. Signed-off-by: Juergen Gross Reviewed-by: Samuel Thibault --- blkfront.c | 4 ++-- console/xencons_ring.c | 2 +- fbfront.c | 12 ++++++------ include/lib.h | 3 ++- netfront.c | 4 ++-- tpm_tis.c | 2 +- tpmfront.c | 6 +++--- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/blkfront.c b/blkfront.c index 834a978..7c8eb74 100644 --- a/blkfront.c +++ b/blkfront.c @@ -62,7 +62,7 @@ void blkfront_handler(evtchn_port_t port, struct pt_regs = *regs, void *data) int fd =3D dev->fd; =20 if (fd !=3D -1) - files[fd].read =3D 1; + files[fd].read =3D true; #endif wake_up(&blkfront_queue); } @@ -484,7 +484,7 @@ int blkfront_aio_poll(struct blkfront_dev *dev) moretodo: #ifdef HAVE_LIBC if (dev->fd !=3D -1) { - files[dev->fd].read =3D 0; + files[dev->fd].read =3D false; mb(); /* Make sure to let the handler set read to 1 before we star= t looking at the ring */ } #endif diff --git a/console/xencons_ring.c b/console/xencons_ring.c index b6db74e..c348f3c 100644 --- a/console/xencons_ring.c +++ b/console/xencons_ring.c @@ -102,7 +102,7 @@ void console_handle_input(evtchn_port_t port, struct pt= _regs *regs, void *data) int fd =3D dev ? dev->fd : -1; =20 if (fd !=3D -1) - files[fd].read =3D 1; + files[fd].read =3D true; =20 wake_up(&console_queue); #else diff --git a/fbfront.c b/fbfront.c index d3b3848..6725da1 100644 --- a/fbfront.c +++ b/fbfront.c @@ -45,7 +45,7 @@ void kbdfront_handler(evtchn_port_t port, struct pt_regs = *regs, void *data) int fd =3D dev->fd; =20 if (fd !=3D -1) - files[fd].read =3D 1; + files[fd].read =3D true; #endif wake_up(&kbdfront_queue); } @@ -207,7 +207,7 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xe= nkbd_in_event *buf, int n =20 #ifdef HAVE_LIBC if (dev->fd !=3D -1) { - files[dev->fd].read =3D 0; + files[dev->fd].read =3D false; mb(); /* Make sure to let the handler set read to 1 before we star= t looking at the ring */ } #endif @@ -229,7 +229,7 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xe= nkbd_in_event *buf, int n #ifdef HAVE_LIBC if (cons !=3D prod && dev->fd !=3D -1) /* still some events to read */ - files[dev->fd].read =3D 1; + files[dev->fd].read =3D true; #endif =20 return i; @@ -349,7 +349,7 @@ void fbfront_handler(evtchn_port_t port, struct pt_regs= *regs, void *data) int fd =3D dev->fd; =20 if (fd !=3D -1) - files[fd].read =3D 1; + files[fd].read =3D true; #endif wake_up(&fbfront_queue); } @@ -376,7 +376,7 @@ int fbfront_receive(struct fbfront_dev *dev, union xenf= b_in_event *buf, int n) =20 #ifdef HAVE_LIBC if (dev->fd !=3D -1) { - files[dev->fd].read =3D 0; + files[dev->fd].read =3D false; mb(); /* Make sure to let the handler set read to 1 before we star= t looking at the ring */ } #endif @@ -398,7 +398,7 @@ int fbfront_receive(struct fbfront_dev *dev, union xenf= b_in_event *buf, int n) #ifdef HAVE_LIBC if (cons !=3D prod && dev->fd !=3D -1) /* still some events to read */ - files[dev->fd].read =3D 1; + files[dev->fd].read =3D true; #endif =20 return i; diff --git a/include/lib.h b/include/lib.h index a638bc9..df2de9e 100644 --- a/include/lib.h +++ b/include/lib.h @@ -49,6 +49,7 @@ #define _LIB_H_ =20 #include +#include #include #include #include @@ -183,6 +184,7 @@ struct evtchn_port_info { =20 struct file { enum fd_type type; + bool read; /* maybe available for read */ union { struct { /* lwIP fd */ @@ -235,7 +237,6 @@ struct file { } xenbus; #endif }; - int read; /* maybe available for read */ }; =20 extern struct file files[]; diff --git a/netfront.c b/netfront.c index dfe065b..a566e34 100644 --- a/netfront.c +++ b/netfront.c @@ -255,7 +255,7 @@ void netfront_select_handler(evtchn_port_t port, struct= pt_regs *regs, void *dat local_irq_restore(flags); =20 if (fd !=3D -1) - files[fd].read =3D 1; + files[fd].read =3D true; wake_up(&netfront_queue); } #endif @@ -783,7 +783,7 @@ ssize_t netfront_receive(struct netfront_dev *dev, unsi= gned char *data, size_t l network_rx(dev); if (!dev->rlen && fd !=3D -1) /* No data for us, make select stop returning */ - files[fd].read =3D 0; + files[fd].read =3D false; /* Before re-enabling the interrupts, in case a packet just arrived in= the * meanwhile. */ local_irq_restore(flags); diff --git a/tpm_tis.c b/tpm_tis.c index 475ac5d..4a51027 100644 --- a/tpm_tis.c +++ b/tpm_tis.c @@ -845,7 +845,7 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, si= ze_t len) { } #ifdef HAVE_LIBC if(tpm->fd >=3D 0) { - files[tpm->fd].read =3D 0; + files[tpm->fd].read =3D false; files[tpm->fd].tpm_tis.respgot =3D 0; files[tpm->fd].tpm_tis.offset =3D 0; } diff --git a/tpmfront.c b/tpmfront.c index 6049244..d825b49 100644 --- a/tpmfront.c +++ b/tpmfront.c @@ -66,7 +66,7 @@ void tpmfront_handler(evtchn_port_t port, struct pt_regs = *regs, void *data) { dev->waiting =3D 0; #ifdef HAVE_LIBC if(dev->fd >=3D 0) { - files[dev->fd].read =3D 1; + files[dev->fd].read =3D true; } #endif wake_up(&dev->waitq); @@ -438,7 +438,7 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8= _t* msg, size_t length) dev->resplen =3D 0; #ifdef HAVE_LIBC if(dev->fd >=3D 0) { - files[dev->fd].read =3D 0; + files[dev->fd].read =3D false; files[dev->fd].tpmfront.respgot =3D 0; files[dev->fd].tpmfront.offset =3D 0; } @@ -611,7 +611,7 @@ int tpmfront_posix_fstat(int fd, struct stat* buf) =20 /* If we have a response waiting, then read it now from the backend * so we can get its length*/ - if(dev->waiting || (files[dev->fd].read =3D=3D 1 && !files[dev->fd].tpm= front.respgot)) { + if(dev->waiting || (files[dev->fd].read && !files[dev->fd].tpmfront.res= pgot)) { if ((rc =3D tpmfront_recv(dev, &dummybuf, &dummysz)) !=3D 0) { errno =3D EIO; return -1; --=20 2.26.2