From nobody Thu Apr 25 15:04:29 2024 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=1641470311; cv=none; d=zohomail.com; s=zohoarc; b=d5i5CCVYaAUMqQA7pmEW6KYQW8RTdQ8/RU8Crcq+PPMMX3D1Qf79zWqs8cR6ySo455zroS86rwcaPn4nQVLTsfQ4gVbTZ05W8QdlbnjLvbygauF3CkKpCKd+2q1AI+DLgRIyUkgBvW0imNXDwo5lZNXt6dq5doAIzMY3CAmU4Gc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641470311; 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=5R3ZzVCzkcurvfIiXoJfZKNipObEjTIYIL/twAPEHmg=; b=R7Cwdgw2nvomXivQ0YMuvLw1wJipjH+2ReF66oByQtmYLukPGS2ikHdFmmdUL9QwcwztuCS3iBS3g7jlbMogtL/CA0StdGILoRtbHYrzUdt0x1P/CEkcwRvfHH+e4KD3PCvajrXT1gra4VfjIeL42X12trYhPb5JH+ZQWRUNxG0= 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 1641470311283530.5747707208756; Thu, 6 Jan 2022 03:58:31 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.253906.435213 (Exim 4.92) (envelope-from ) id 1n5RP6-0005X3-Gz; Thu, 06 Jan 2022 11:58:00 +0000 Received: by outflank-mailman (output) from mailman id 253906.435213; Thu, 06 Jan 2022 11:58:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RP6-0005Ww-Cq; Thu, 06 Jan 2022 11:58:00 +0000 Received: by outflank-mailman (input) for mailman id 253906; Thu, 06 Jan 2022 11:57:58 +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 1n5RP4-0005UX-TC for xen-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:57:58 +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 e25b206b-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 69607212C7; 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 3FA9513C4A; 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 GIlQDkPZ1mHnJgAAMHmgww (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: e25b206b-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=5R3ZzVCzkcurvfIiXoJfZKNipObEjTIYIL/twAPEHmg=; b=GYmLaoTdv9YvOlvBOvK4jAtMwhOJg02clrHMZYqdYH2gUP1tTILJ7o37Z7FQ5HO9wAmyrg El4HB+u1kC1aILpOQx/jAZ086aghL5uPyYeTLbrCTIPQZUnylW1T3F8KWm0rcei1XFxUvF l+oBSTjAAbERdNv+A6AlQQg+WbaIGrA= 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 01/15] mini-os: split struct file definition from its usage Date: Thu, 6 Jan 2022 12:57:27 +0100 Message-Id: <20220106115741.3219-2-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: 1641470312659100013 Content-Type: text/plain; charset="utf-8" Make the struct file definition standalone and use it for the declaration of the files array. Signed-off-by: Juergen Gross Acked-by: Samuel Thibault Reviewed-by: Samuel Thibault --- include/lib.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/lib.h b/include/lib.h index 39d6a18..a638bc9 100644 --- a/include/lib.h +++ b/include/lib.h @@ -181,7 +181,7 @@ struct evtchn_port_info { int bound; }; =20 -extern struct file { +struct file { enum fd_type type; union { struct { @@ -236,7 +236,9 @@ extern struct file { #endif }; int read; /* maybe available for read */ -} files[]; +}; + +extern struct file files[]; =20 int alloc_fd(enum fd_type type); void close_all_files(void); --=20 2.26.2 From nobody Thu Apr 25 15:04:29 2024 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 Acked-by: Samuel Thibault 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 From nobody Thu Apr 25 15:04:29 2024 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=1641470368; cv=none; d=zohomail.com; s=zohoarc; b=LfgeCGHMiMvjNudKdfiqO1XKnPq7J0Ttuo2SVGYf43CuO/qfqeGoX4DrK5LZfgnt2WZ/saBCrOHW7Uo6EbhNIMTfRx6k7yv7+dPMUJGFZVKJJSjUhLvPsQn9OhDHMBLMP7AEOSfDdoV4b+V28D1AWzcRBDJmL8RUv414ZCO5ncM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641470368; 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=x+0vw1I/hfTGOGb3eceoyxjODZK0aOUWRIC/lcz6R4A=; b=hvkARmUoykwAJazWzGAN4PVeamI2A+1nmXUE0lIhbof5jmzlg1B2KSRh67LiDIlXIBVlWoaYRhbfMusbYygsy4D4P0/De+hqvCWr8XkVlmLRg1Yw8BAN7hFtfTZKGRIthRxk3+mQ+qWWBbUCKRPAY51dlfpCWfQPIvyzTRhLD84= 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 1641470368910965.793525394713; Thu, 6 Jan 2022 03:59:28 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.253928.435362 (Exim 4.92) (envelope-from ) id 1n5RQ8-0003RI-S2; Thu, 06 Jan 2022 11:59:04 +0000 Received: by outflank-mailman (output) from mailman id 253928.435362; Thu, 06 Jan 2022 11:59:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RQ8-0003R7-On; Thu, 06 Jan 2022 11:59:04 +0000 Received: by outflank-mailman (input) for mailman id 253928; Thu, 06 Jan 2022 11:59:04 +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 1n5RPI-0005UX-V6 for xen-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:13 +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 e291ef39-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 C6A48212CA; 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 9D50413C0D; 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 kEA3JUPZ1mHnJgAAMHmgww (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: e291ef39-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=x+0vw1I/hfTGOGb3eceoyxjODZK0aOUWRIC/lcz6R4A=; b=DnqYS+/rPg5//MChMz/HOdqP5Q1i1bqqVHyPWXD5pJruUm9Y4E6Nocyg5xuU88hFWGpuTe uO+ouVJC7JCpecOGRkZJRapyFPp4pzys7X1krV8/MHNO/Rqf7NL/wdzWh1RITCv84zdV1w UVYvnXlsqpLGYSIfOfgR5KDTAyewOJE= 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 03/15] mini-os: make offset a common struct file member for all types Date: Thu, 6 Jan 2022 12:57:29 +0100 Message-Id: <20220106115741.3219-4-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: 1641470371157100001 Content-Type: text/plain; charset="utf-8" Currently 4 file types have an offset member in their private struct file part. Make offset a common struct member shared by all file types. Signed-off-by: Juergen Gross Acked-by: Samuel Thibault Reviewed-by: Samuel Thibault --- blkfront.c | 5 ++--- include/lib.h | 5 +---- lib/sys.c | 14 +++++--------- tpm_tis.c | 11 +++++------ tpmfront.c | 11 +++++------ 5 files changed, 18 insertions(+), 28 deletions(-) diff --git a/blkfront.c b/blkfront.c index 7c8eb74..8137106 100644 --- a/blkfront.c +++ b/blkfront.c @@ -563,14 +563,13 @@ int blkfront_open(struct blkfront_dev *dev) dev->fd =3D alloc_fd(FTYPE_BLK); printk("blk_open(%s) -> %d\n", dev->nodename, dev->fd); files[dev->fd].blk.dev =3D dev; - files[dev->fd].blk.offset =3D 0; return dev->fd; } =20 int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write) { struct blkfront_dev* dev =3D files[fd].blk.dev; - off_t offset =3D files[fd].blk.offset; + off_t offset =3D files[fd].offset; struct blkfront_aiocb aiocb; unsigned long long disksize =3D dev->info.sectors * dev->info.sector_si= ze; unsigned int blocksize =3D dev->info.sector_size; @@ -712,7 +711,7 @@ int blkfront_posix_rwop(int fd, uint8_t* buf, size_t co= unt, int write) } =20 free(copybuf); - files[fd].blk.offset +=3D rc; + files[fd].offset +=3D rc; return rc; =20 } diff --git a/include/lib.h b/include/lib.h index df2de9e..4d9b14b 100644 --- a/include/lib.h +++ b/include/lib.h @@ -185,6 +185,7 @@ struct evtchn_port_info { struct file { enum fd_type type; bool read; /* maybe available for read */ + off_t offset; union { struct { /* lwIP fd */ @@ -193,7 +194,6 @@ struct file { struct { /* FS import fd */ int fd; - off_t offset; } file; struct { struct evtchn_port_list ports; @@ -204,7 +204,6 @@ struct file { } tap; struct { struct blkfront_dev *dev; - off_t offset; } blk; struct { struct kbdfront_dev *dev; @@ -219,14 +218,12 @@ struct file { struct { struct tpmfront_dev *dev; int respgot; - off_t offset; } tpmfront; #endif #ifdef CONFIG_TPM_TIS struct { struct tpm_chip *dev; int respgot; - off_t offset; } tpm_tis; #endif #ifdef CONFIG_XENBUS diff --git a/lib/sys.c b/lib/sys.c index e8d5eb2..e1cea70 100644 --- a/lib/sys.c +++ b/lib/sys.c @@ -107,6 +107,7 @@ int alloc_fd(enum fd_type type) for (i=3D0; ifd >=3D 0) { files[tpm->fd].read =3D false; files[tpm->fd].tpm_tis.respgot =3D 0; - files[tpm->fd].tpm_tis.offset =3D 0; + files[tpm->fd].offset =3D 0; } #endif return len; @@ -1290,7 +1290,6 @@ int tpm_tis_open(struct tpm_chip* tpm) tpm->fd =3D alloc_fd(FTYPE_TPM_TIS); printk("tpm_tis_open() -> %d\n", tpm->fd); files[tpm->fd].tpm_tis.dev =3D tpm; - files[tpm->fd].tpm_tis.offset =3D 0; files[tpm->fd].tpm_tis.respgot =3D 0; return tpm->fd; } @@ -1340,13 +1339,13 @@ int tpm_tis_posix_read(int fd, uint8_t* buf, size_t= count) =20 =20 /* Handle EOF case */ - if(files[fd].tpm_tis.offset >=3D tpm->data_len) { + if(files[fd].offset >=3D tpm->data_len) { rc =3D 0; } else { - rc =3D min(tpm->data_len - files[fd].tpm_tis.offset, count); - memcpy(buf, tpm->data_buffer + files[fd].tpm_tis.offset, rc); + rc =3D min(tpm->data_len - files[fd].offset, count); + memcpy(buf, tpm->data_buffer + files[fd].offset, rc); } - files[fd].tpm_tis.offset +=3D rc; + files[fd].offset +=3D rc; /* Reset the data pending flag */ return rc; } diff --git a/tpmfront.c b/tpmfront.c index d825b49..8b2a910 100644 --- a/tpmfront.c +++ b/tpmfront.c @@ -440,7 +440,7 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8= _t* msg, size_t length) if(dev->fd >=3D 0) { files[dev->fd].read =3D false; files[dev->fd].tpmfront.respgot =3D 0; - files[dev->fd].tpmfront.offset =3D 0; + files[dev->fd].offset =3D 0; } #endif wmb(); @@ -539,7 +539,6 @@ int tpmfront_open(struct tpmfront_dev* dev) dev->fd =3D alloc_fd(FTYPE_TPMFRONT); printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd); files[dev->fd].tpmfront.dev =3D dev; - files[dev->fd].tpmfront.offset =3D 0; files[dev->fd].tpmfront.respgot =3D 0; return dev->fd; } @@ -589,14 +588,14 @@ int tpmfront_posix_read(int fd, uint8_t* buf, size_t = count) } =20 /* handle EOF case */ - if(files[dev->fd].tpmfront.offset >=3D dev->resplen) { + if(files[dev->fd].offset >=3D dev->resplen) { return 0; } =20 /* Compute the number of bytes and do the copy operation */ - if((rc =3D min(count, dev->resplen - files[dev->fd].tpmfront.offset)) != =3D 0) { - memcpy(buf, dev->respbuf + files[dev->fd].tpmfront.offset, rc); - files[dev->fd].tpmfront.offset +=3D rc; + if((rc =3D min(count, dev->resplen - files[dev->fd].offset)) !=3D 0) { + memcpy(buf, dev->respbuf + files[dev->fd].offset, rc); + files[dev->fd].offset +=3D rc; } =20 return rc; --=20 2.26.2 From nobody Thu Apr 25 15:04:29 2024 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=1641470309; cv=none; d=zohomail.com; s=zohoarc; b=YH90/B0PhPtRcpsuTe0L5mE3+hNaDLOncSuANGw4JLwF5R2CAz9qURSLcLmR1Np8tf4Q3XGqtZYv3O5u+eAO5VFNDSdQVMd+ewGqamBZvr5tU/mYQd6j4wwb57TRQsg6+zgCHQcE8dwADleB99lyAxSnGPK8KBQKCMMGXzuylAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641470309; 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=51rtfDlnCwvtylJO0A+QuSOibmO2F89Q2mcJem6Kck0=; b=HJFoCgfKBSLPyoyuj6rDkvSataRdg8/vQlyUELDaeRincJQI+TLUOOcphjq+hmN7SUWiDDU+skQ3/wY3knLxlYqFgfBoJknXnliMJMj553SUWmw1xWPtyRHOL23/DOBKUq91LyWdgpDYGYaQLJhfmAhtQW7diK/seddztjHUgeQ= 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 1641470309309654.7494367345984; Thu, 6 Jan 2022 03:58:29 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.253914.435270 (Exim 4.92) (envelope-from ) id 1n5RPA-0006fi-GV; Thu, 06 Jan 2022 11:58:04 +0000 Received: by outflank-mailman (output) from mailman id 253914.435270; Thu, 06 Jan 2022 11:58:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RPA-0006eH-Af; Thu, 06 Jan 2022 11:58:04 +0000 Received: by outflank-mailman (input) for mailman id 253914; Thu, 06 Jan 2022 11:58:02 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RP8-0005Uf-Hj for xen-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:02 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e2aad614-6ee7-11ec-9ce5-af14b9085ebd; 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 02273212CB; Thu, 6 Jan 2022 11:57:56 +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 CB74C13C0D; 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 qKd1MEPZ1mHnJgAAMHmgww (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: e2aad614-6ee7-11ec-9ce5-af14b9085ebd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641470276; 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=51rtfDlnCwvtylJO0A+QuSOibmO2F89Q2mcJem6Kck0=; b=IvjSX2gexxgKdcxmktE+tINJhUGi/QHxpWqsA/JpnM5W2NBqMGPuSUjvaFJVxQeA5wmZjW OT3La1KL4bWX7a/BiEaFOG1LvEHxW4lWZYOk7Fp5s/0sN6CaP2Px082/dvXYmca2T+VlTK 7CGQ19MKJH7vWWNYzP8tE+dm9LJ5g4A= 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 04/15] mini-os: replace multiple fd elements in struct file by common one Date: Thu, 6 Jan 2022 12:57:30 +0100 Message-Id: <20220106115741.3219-5-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: 1641470310754100007 Content-Type: text/plain; charset="utf-8" The type specific union in struct files contains two instances of "int fd". Replace them by a common one. Signed-off-by: Juergen Gross Acked-by: Samuel Thibault Reviewed-by: Samuel Thibault --- include/lib.h | 9 +-------- lib/sys.c | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/include/lib.h b/include/lib.h index 4d9b14b..dc56f52 100644 --- a/include/lib.h +++ b/include/lib.h @@ -187,14 +187,7 @@ struct file { bool read; /* maybe available for read */ off_t offset; union { - struct { - /* lwIP fd */ - int fd; - } socket; - struct { - /* FS import fd */ - int fd; - } file; + int fd; /* Any fd from an upper layer. */ struct { struct evtchn_port_list ports; } evtchn; diff --git a/lib/sys.c b/lib/sys.c index e1cea70..1da7401 100644 --- a/lib/sys.c +++ b/lib/sys.c @@ -258,7 +258,7 @@ int read(int fd, void *buf, size_t nbytes) } #ifdef HAVE_LWIP case FTYPE_SOCKET: - return lwip_read(files[fd].socket.fd, buf, nbytes); + return lwip_read(files[fd].fd, buf, nbytes); #endif #ifdef CONFIG_NETFRONT case FTYPE_TAP: { @@ -335,7 +335,7 @@ int write(int fd, const void *buf, size_t nbytes) return nbytes; #ifdef HAVE_LWIP case FTYPE_SOCKET: - return lwip_write(files[fd].socket.fd, (void*) buf, nbytes); + return lwip_write(files[fd].fd, (void*) buf, nbytes); #endif #ifdef CONFIG_NETFRONT case FTYPE_TAP: @@ -428,7 +428,7 @@ int close(int fd) #endif #ifdef HAVE_LWIP case FTYPE_SOCKET: { - int res =3D lwip_close(files[fd].socket.fd); + int res =3D lwip_close(files[fd].fd); files[fd].type =3D FTYPE_NONE; return res; } @@ -594,7 +594,7 @@ int fcntl(int fd, int cmd, ...) if (files[fd].type =3D=3D FTYPE_SOCKET && !(arg & ~O_NONBLOCK)) { /* Only flag supported: non-blocking mode */ uint32_t nblock =3D !!(arg & O_NONBLOCK); - return lwip_ioctl(files[fd].socket.fd, FIONBIO, &nblock); + return lwip_ioctl(files[fd].fd, FIONBIO, &nblock); } /* Fallthrough */ #endif @@ -732,15 +732,15 @@ static int select_poll(int nfds, fd_set *readfds, fd_= set *writefds, fd_set *exce for (i =3D 0; i < nfds; i++) { if (files[i].type =3D=3D FTYPE_SOCKET) { if (FD_ISSET(i, readfds)) { - FD_SET(files[i].socket.fd, &sock_readfds); + FD_SET(files[i].fd, &sock_readfds); sock_nfds =3D i+1; } if (FD_ISSET(i, writefds)) { - FD_SET(files[i].socket.fd, &sock_writefds); + FD_SET(files[i].fd, &sock_writefds); sock_nfds =3D i+1; } if (FD_ISSET(i, exceptfds)) { - FD_SET(files[i].socket.fd, &sock_exceptfds); + FD_SET(files[i].fd, &sock_exceptfds); sock_nfds =3D i+1; } } @@ -803,19 +803,19 @@ static int select_poll(int nfds, fd_set *readfds, fd_= set *writefds, fd_set *exce case FTYPE_SOCKET: if (FD_ISSET(i, readfds)) { /* Optimize no-network-packet case. */ - if (sock_n && FD_ISSET(files[i].socket.fd, &sock_readfds)) + if (sock_n && FD_ISSET(files[i].fd, &sock_readfds)) n++; else FD_CLR(i, readfds); } if (FD_ISSET(i, writefds)) { - if (sock_n && FD_ISSET(files[i].socket.fd, &sock_writefds)) + if (sock_n && FD_ISSET(files[i].fd, &sock_writefds)) n++; else FD_CLR(i, writefds); } if (FD_ISSET(i, exceptfds)) { - if (sock_n && FD_ISSET(files[i].socket.fd, &sock_exceptfds)) + if (sock_n && FD_ISSET(files[i].fd, &sock_exceptfds)) n++; else FD_CLR(i, exceptfds); @@ -1112,7 +1112,7 @@ int socket(int domain, int type, int protocol) return -1; res =3D alloc_fd(FTYPE_SOCKET); printk("socket -> %d\n", res); - files[res].socket.fd =3D fd; + files[res].fd =3D fd; return res; } =20 @@ -1124,11 +1124,11 @@ int accept(int s, struct sockaddr *addr, socklen_t = *addrlen) errno =3D EBADF; return -1; } - fd =3D lwip_accept(files[s].socket.fd, addr, addrlen); + fd =3D lwip_accept(files[s].fd, addr, addrlen); if (fd < 0) return -1; res =3D alloc_fd(FTYPE_SOCKET); - files[res].socket.fd =3D fd; + files[res].fd =3D fd; printk("accepted on %d -> %d\n", s, res); return res; } @@ -1141,7 +1141,7 @@ ret name proto \ errno =3D EBADF; \ return -1; \ } \ - s =3D files[s].socket.fd; \ + s =3D files[s].fd; \ return lwip_##name args; \ } =20 --=20 2.26.2 From nobody Thu Apr 25 15:04:29 2024 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=1641470311; cv=none; d=zohomail.com; s=zohoarc; b=n2viTG050damI+H4ttGaRNeze8HO+IazcWODLvsIlmO206IOObQ26kzdfOwj2nw6rSHIww20T8XNIgDGOPqVPwxAvEMjYhnqrD472nlkPtldFFxevhAy7wef3j7mSb45Q+mClIVK7RR9XkzKrXYZCOsRBNXE9sedKRCcZ4p6wns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641470311; 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=tru95lucHl6eXrRSEYruYf0s6MYSR/EyxinHg1pggO4=; b=iDVj7vthE10GN7QoekG7Mvf/ryn303acH6n2F4ioC6rU1NpyUwbhk3enJDwuWfNNmMSILu5SfbSLfw7O8Sow4u7O/c+27nQApIzBkA1dS7UclzvmG85hoh636J6+MpsC+YJgZ55nJ1zul8sqbMHevk1tW1pTOgNEgrLwe2gkVzc= 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 1641470311310956.8314584245348; Thu, 6 Jan 2022 03:58:31 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.253911.435246 (Exim 4.92) (envelope-from ) id 1n5RP8-000656-Cs; Thu, 06 Jan 2022 11:58:02 +0000 Received: by outflank-mailman (output) from mailman id 253911.435246; Thu, 06 Jan 2022 11:58:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RP8-00064G-7B; Thu, 06 Jan 2022 11:58:02 +0000 Received: by outflank-mailman (input) for mailman id 253911; Thu, 06 Jan 2022 11:58:01 +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 1n5RP6-0005UX-TZ for xen-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:00 +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 e2cc6d54-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 366F4212CC; Thu, 6 Jan 2022 11:57:56 +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 0300413C4A; 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 EOQ0O0PZ1mHnJgAAMHmgww (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: e2cc6d54-6ee7-11ec-81c0-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641470276; 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=tru95lucHl6eXrRSEYruYf0s6MYSR/EyxinHg1pggO4=; b=fmz1LjyfMYD45R5dtM/5FppITveTaKMBnCxcp5u+H90M+u/rLZ2qgn5y/Q1sGv+gqgantT zDfi7S/BqLf1DvsOm6Hs7kDtIoet8QicZZBKW/TZVHUa23mV3cjYkcGOiK/JojiXXY0VMu MKhmsH0TsZytENYwJWvROX3ruUOcx5g= 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 05/15] mini-os: introduce a common dev pointer in struct file Date: Thu, 6 Jan 2022 12:57:31 +0100 Message-Id: <20220106115741.3219-6-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: 1641470312666100014 Content-Type: text/plain; charset="utf-8" There are many dev pointers in a union in struct file. Prepare to switch to a single one by introducing a new common one. Signed-off-by: Juergen Gross Acked-by: Samuel Thibault Reviewed-by: Samuel Thibault --- include/lib.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/lib.h b/include/lib.h index dc56f52..60aaf1c 100644 --- a/include/lib.h +++ b/include/lib.h @@ -188,6 +188,7 @@ struct file { off_t offset; union { int fd; /* Any fd from an upper layer. */ + void *dev; struct { struct evtchn_port_list ports; } evtchn; --=20 2.26.2 From nobody Thu Apr 25 15:04:29 2024 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=1641470309; cv=none; d=zohomail.com; s=zohoarc; b=TyDtsSQvoyjk8Vae3uE33osu7eH0Rsj4/nuZiEOxFSkS78c7ZWiqjaUmTPfOdA1OOC2iYYRBqXlB+/iP/yAOT1hDsvQf2MY3hrtuRSf8NhGOWx9EwaFVDBYtbyNVh/Ks08DXBsHaKq4xbh0GULgk5NUQJsHLscMHu8VNOOXrzYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641470309; 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=bmVybJWUa0fFpI1LcBKz9xhn6xImelv7T4pQq8L9wmI=; b=gs8Mokb8KClqVwz/NmrrH0y9EdvX/S3zXm3rM/+NOgfaobR4xYbxNJ2bEWUsuqNU7r3BJZ/cMQmlRXZQsYjUWGROr0EflhvxEMi76HnkFPAis8QfG1MPrbZTTpAcjgmspet2k2pibo5kdNYYgeUEE4T3Iu24uH9sqO9jytW2/tw= 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 1641470309628659.7407828763562; Thu, 6 Jan 2022 03:58:29 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.253912.435253 (Exim 4.92) (envelope-from ) id 1n5RP9-0006GL-3o; Thu, 06 Jan 2022 11:58:03 +0000 Received: by outflank-mailman (output) from mailman id 253912.435253; Thu, 06 Jan 2022 11:58:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RP8-0006Di-Pa; Thu, 06 Jan 2022 11:58:02 +0000 Received: by outflank-mailman (input) for mailman id 253912; Thu, 06 Jan 2022 11:58:01 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RP7-0005Uf-Hh for xen-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:01 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e38d72f9-6ee7-11ec-9ce5-af14b9085ebd; 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 65C0B212FE; Thu, 6 Jan 2022 11:57:56 +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 3BE7213C0D; Thu, 6 Jan 2022 11:57:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uGJfDUTZ1mHnJgAAMHmgww (envelope-from ); Thu, 06 Jan 2022 11:57:56 +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: e38d72f9-6ee7-11ec-9ce5-af14b9085ebd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641470276; 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=bmVybJWUa0fFpI1LcBKz9xhn6xImelv7T4pQq8L9wmI=; b=Fs+UM/pWdDVvJXN8OAMiyiD3OkCUNAbWinIFWd/F0qaF9KZkPplY/ZsLiQrZC5bn42+yzU DXYYsyjqIiH0Rcz4eufKAnteQTq+nh0x3TnCxrLaV/ystB9ur0TWc/5DIhjbgmzk3M7jbW H9NWENjKQdu5+qgvy5/2JYb2t1p3E/s= 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 06/15] mini-os: eliminate blkfront union member in struct file Date: Thu, 6 Jan 2022 12:57:32 +0100 Message-Id: <20220106115741.3219-7-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: 1641470310684100003 Content-Type: text/plain; charset="utf-8" Replace the blkfront specific union member in struct file with the common dev pointer. Signed-off-by: Juergen Gross Acked-by: Samuel Thibault Reviewed-by: Samuel Thibault --- blkfront.c | 6 +++--- include/lib.h | 3 --- lib/sys.c | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/blkfront.c b/blkfront.c index 8137106..e3f42be 100644 --- a/blkfront.c +++ b/blkfront.c @@ -562,13 +562,13 @@ int blkfront_open(struct blkfront_dev *dev) } dev->fd =3D alloc_fd(FTYPE_BLK); printk("blk_open(%s) -> %d\n", dev->nodename, dev->fd); - files[dev->fd].blk.dev =3D dev; + files[dev->fd].dev =3D dev; return dev->fd; } =20 int blkfront_posix_rwop(int fd, uint8_t* buf, size_t count, int write) { - struct blkfront_dev* dev =3D files[fd].blk.dev; + struct blkfront_dev* dev =3D files[fd].dev; off_t offset =3D files[fd].offset; struct blkfront_aiocb aiocb; unsigned long long disksize =3D dev->info.sectors * dev->info.sector_si= ze; @@ -718,7 +718,7 @@ int blkfront_posix_rwop(int fd, uint8_t* buf, size_t co= unt, int write) =20 int blkfront_posix_fstat(int fd, struct stat* buf) { - struct blkfront_dev* dev =3D files[fd].blk.dev; + struct blkfront_dev* dev =3D files[fd].dev; =20 buf->st_mode =3D dev->info.mode; buf->st_uid =3D 0; diff --git a/include/lib.h b/include/lib.h index 60aaf1c..3a40634 100644 --- a/include/lib.h +++ b/include/lib.h @@ -196,9 +196,6 @@ struct file { struct { struct netfront_dev *dev; } tap; - struct { - struct blkfront_dev *dev; - } blk; struct { struct kbdfront_dev *dev; } kbd; diff --git a/lib/sys.c b/lib/sys.c index 1da7401..f2fdbdf 100644 --- a/lib/sys.c +++ b/lib/sys.c @@ -456,7 +456,7 @@ int close(int fd) #endif #ifdef CONFIG_BLKFRONT case FTYPE_BLK: - shutdown_blkfront(files[fd].blk.dev); + shutdown_blkfront(files[fd].dev); files[fd].type =3D FTYPE_NONE; return 0; #endif --=20 2.26.2 From nobody Thu Apr 25 15:04:29 2024 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=1641470450; cv=none; d=zohomail.com; s=zohoarc; b=K1ESwGCw6nKUpsS71X5GJccAlv4FpHlo2X4vJNROCI8afwUdkX5bH1BrOU1ZyFhw21vGcBMhQatdu8+at+5OMWyWbGndSt/NmmOZtbffbMhlCE/oiFfpZV86rO+8VOl6nKgLyoj79rYYaUNDoTfq9LL2IZJ1sAypDnWZSbJQrYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641470450; 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=0ADnCSUrVKDoJvsP7J4SKuUjUEXMRkB3QXB4kfD1iQE=; b=SLoFM3xRXVX1/sRSLU1OPpZkDgYTimq428YrTWq07lfwTonQtgiB4eAFslIz/SJxD8iSPrAOo6P/mxulL4CakmK51q6cvpGXNO+mspA6nBdnwYz19Wc7TxctVeFjzpQ07FnXjU/r1QLOKCWptTXrd6/A1VLOVsQQlBXIeCJDbhA= 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 1641470450021418.6489579448745; Thu, 6 Jan 2022 04:00:50 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.253965.435430 (Exim 4.92) (envelope-from ) id 1n5RRe-00073q-Si; Thu, 06 Jan 2022 12:00:38 +0000 Received: by outflank-mailman (output) from mailman id 253965.435430; Thu, 06 Jan 2022 12:00:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RRe-00073h-PI; Thu, 06 Jan 2022 12:00:38 +0000 Received: by outflank-mailman (input) for mailman id 253965; Thu, 06 Jan 2022 12:00:37 +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 1n5RPF-0005UX-UT for xen-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:10 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e30200bb-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-out2.suse.de (Postfix) with ESMTPS id 911F11F3A2; Thu, 6 Jan 2022 11:57:56 +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 6968F13C0D; Thu, 6 Jan 2022 11:57:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UFCSGETZ1mHnJgAAMHmgww (envelope-from ); Thu, 06 Jan 2022 11:57:56 +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: e30200bb-6ee7-11ec-81c0-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641470276; 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=0ADnCSUrVKDoJvsP7J4SKuUjUEXMRkB3QXB4kfD1iQE=; b=nkoh468iPXJMcFqUDXHeV++B8pzmUUI5aC7nUnBdGH5ZszTQtPxyUKPq4OU8SHE1WDw+x5 PiPO+hD1IZXECQLPBYmFWcjpe3ilx/KRS9lTA9BFicOUyuumLBMYFQHZBLRtIFj/C/qdSR PjsikQERyv4EHkwiKW4TT7G5ry6t9Vs= 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 07/15] mini-os: eliminate consfront union member in struct file Date: Thu, 6 Jan 2022 12:57:33 +0100 Message-Id: <20220106115741.3219-8-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: 1641470451952100001 Content-Type: text/plain; charset="utf-8" Replace the consfront specific union member in struct file with the common dev pointer. Signed-off-by: Juergen Gross Acked-by: Samuel Thibault Reviewed-by: Samuel Thibault --- include/lib.h | 3 --- lib/sys.c | 31 +++++++++++++++++-------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/lib.h b/include/lib.h index 3a40634..0cedae6 100644 --- a/include/lib.h +++ b/include/lib.h @@ -202,9 +202,6 @@ struct file { struct { struct fbfront_dev *dev; } fb; - struct { - struct consfront_dev *dev; - } cons; #ifdef CONFIG_TPMFRONT struct { struct tpmfront_dev *dev; diff --git a/lib/sys.c b/lib/sys.c index f2fdbdf..62c2020 100644 --- a/lib/sys.c +++ b/lib/sys.c @@ -179,7 +179,7 @@ int posix_openpt(int flags) =20 dev =3D init_consfront(NULL); dev->fd =3D alloc_fd(FTYPE_CONSOLE); - files[dev->fd].cons.dev =3D dev; + files[dev->fd].dev =3D dev; =20 printk("fd(%d) =3D posix_openpt\n", dev->fd); return(dev->fd); @@ -194,7 +194,7 @@ int open_savefile(const char *path, int save) =20 dev =3D init_consfront(nodename); dev->fd =3D alloc_fd(FTYPE_SAVEFILE); - files[dev->fd].cons.dev =3D dev; + files[dev->fd].dev =3D dev; =20 printk("fd(%d) =3D open_savefile\n", dev->fd); return(dev->fd); @@ -248,7 +248,7 @@ int read(int fd, void *buf, size_t nbytes) DEFINE_WAIT(w); while(1) { add_waiter(w, console_queue); - ret =3D xencons_ring_recv(files[fd].cons.dev, buf, nbytes); + ret =3D xencons_ring_recv(files[fd].dev, buf, nbytes); if (ret) break; schedule(); @@ -324,14 +324,14 @@ int write(int fd, const void *buf, size_t nbytes) case FTYPE_SAVEFILE: { int ret =3D 0, tot =3D nbytes; while (nbytes > 0) { - ret =3D xencons_ring_send(files[fd].cons.dev, (char *)= buf, nbytes); + ret =3D xencons_ring_send(files[fd].dev, (char *)buf, = nbytes); nbytes -=3D ret; buf =3D (char *)buf + ret; } return tot - nbytes; } case FTYPE_CONSOLE: - console_print(files[fd].cons.dev, (char *)buf, nbytes); + console_print(files[fd].dev, (char *)buf, nbytes); return nbytes; #ifdef HAVE_LWIP case FTYPE_SOCKET: @@ -487,7 +487,7 @@ int close(int fd) #ifdef CONFIG_CONSFRONT case FTYPE_SAVEFILE: case FTYPE_CONSOLE: - fini_consfront(files[fd].cons.dev); + fini_consfront(files[fd].dev); files[fd].type =3D FTYPE_NONE; return 0; #endif @@ -764,7 +764,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_se= t *writefds, fd_set *exce /* Fallthrough. */ case FTYPE_CONSOLE: if (FD_ISSET(i, readfds)) { - if (xencons_ring_avail(files[i].cons.dev)) + if (xencons_ring_avail(files[i].dev)) n++; else FD_CLR(i, readfds); @@ -1447,6 +1447,8 @@ const struct termios default_termios =3D {0, = /* iflag */ =20 int tcsetattr(int fildes, int action, const struct termios *tios) { + struct consfront_dev *dev; + if (fildes < 0 || fildes >=3D NOFILE) { errno =3D EBADF; return -1; @@ -1472,21 +1474,21 @@ int tcsetattr(int fildes, int action, const struct = termios *tios) return -1; } =20 - if (files[fildes].cons.dev =3D=3D NULL) { + dev =3D files[fildes].dev; + if (dev =3D=3D NULL) { errno =3D ENOSYS; return -1; } =20 - if (tios->c_oflag & OPOST) - files[fildes].cons.dev->is_raw =3D false; - else - files[fildes].cons.dev->is_raw =3D true; + dev->is_raw =3D !(tios->c_oflag & OPOST); =20 return 0; } =20 int tcgetattr(int fildes, struct termios *tios) { + struct consfront_dev *dev; + if (fildes < 0 || fildes >=3D NOFILE) { errno =3D EBADF; return -1; @@ -1497,7 +1499,8 @@ int tcgetattr(int fildes, struct termios *tios) return -1; } =20 - if (files[fildes].cons.dev =3D=3D NULL) { + dev =3D files[fildes].dev; + if (dev =3D=3D NULL) { errno =3D ENOSYS; return 0; } @@ -1509,7 +1512,7 @@ int tcgetattr(int fildes, struct termios *tios) =20 memcpy(tios, &default_termios, sizeof(struct termios)); =20 - if (files[fildes].cons.dev->is_raw) + if (dev->is_raw) tios->c_oflag &=3D ~OPOST; =20 return 0; --=20 2.26.2 From nobody Thu Apr 25 15:04:29 2024 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=1641470308; cv=none; d=zohomail.com; s=zohoarc; b=j+KKAVE8KXRaM2Z/ox6y8Sl4vWgat9o8OOBl6lJ6uMpNrsWGwYD0QiFoLWfaKx4hkGTqYwYKhlq7rYghrAZVPaybwc7Ea95sr6Ai1EebgzMdvoWZZT3I21+wirjb0CUBR67KKNPY9yMYzYTNgrDJzdWhUpxFb2hx3TQvgzsiq20= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641470308; 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=xErc7oBdwTzw610yqw3gpLQCyn3qczdDyg0iihAjKQM=; b=nqPCBYYToPFKY8ZNm7Ff2lQJ0Oiuy5f8Z9U4CQ3yckr15p0BRCVxRyJkAMhqu4L29sofaHrXy44J3N/Lw4yBx4kAVI+R76ibNvrt4KXCJtk55PLpUxHY5kqzYZ1zc/ULcQ9Rc1M9w3DfKsRoSkvu4yfVVltC/sMB9EEpmRUKdQ8= 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 1641470308222831.0581508324213; Thu, 6 Jan 2022 03:58:28 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.253915.435276 (Exim 4.92) (envelope-from ) id 1n5RPB-0006mP-40; Thu, 06 Jan 2022 11:58:05 +0000 Received: by outflank-mailman (output) from mailman id 253915.435276; Thu, 06 Jan 2022 11:58:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RPA-0006lY-QZ; Thu, 06 Jan 2022 11:58:04 +0000 Received: by outflank-mailman (input) for mailman id 253915; Thu, 06 Jan 2022 11:58:03 +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 1n5RP8-0005UX-U5 for xen-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:02 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e3256124-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-out2.suse.de (Postfix) with ESMTPS id C0B481F3A6; Thu, 6 Jan 2022 11:57:56 +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 9736213C0D; Thu, 6 Jan 2022 11:57:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IMWmI0TZ1mHnJgAAMHmgww (envelope-from ); Thu, 06 Jan 2022 11:57:56 +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: e3256124-6ee7-11ec-81c0-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641470276; 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=xErc7oBdwTzw610yqw3gpLQCyn3qczdDyg0iihAjKQM=; b=IPtmfN6P3iEoVunr9mUcXaEj1i9fEgD3m65LtDMKgeHnVLAeEOiyoc4jqCH8r1Bd22Fs8L Id1HWyvbLUUr4Vpj8VUNJaAxMAN+p3bdGBePEoP2sjnWYsNTpDV1K4H/lChVa+MDcsSAki sLfOeG7xXhvmJIT/1PJGOH6yOstLcNU= 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 08/15] mini-os: eliminate fbfront union member in struct file Date: Thu, 6 Jan 2022 12:57:34 +0100 Message-Id: <20220106115741.3219-9-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: 1641470308958100001 Content-Type: text/plain; charset="utf-8" Replace the fbfront specific union member in struct file with the common dev pointer. Signed-off-by: Juergen Gross Acked-by: Samuel Thibault Reviewed-by: Samuel Thibault --- fbfront.c | 2 +- include/lib.h | 3 --- lib/sys.c | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/fbfront.c b/fbfront.c index 6725da1..c8410af 100644 --- a/fbfront.c +++ b/fbfront.c @@ -703,7 +703,7 @@ int fbfront_open(struct fbfront_dev *dev) { dev->fd =3D alloc_fd(FTYPE_FB); printk("fb_open(%s) -> %d\n", dev->nodename, dev->fd); - files[dev->fd].fb.dev =3D dev; + files[dev->fd].dev =3D dev; return dev->fd; } #endif diff --git a/include/lib.h b/include/lib.h index 0cedae6..2a9a01c 100644 --- a/include/lib.h +++ b/include/lib.h @@ -199,9 +199,6 @@ struct file { struct { struct kbdfront_dev *dev; } kbd; - struct { - struct fbfront_dev *dev; - } fb; #ifdef CONFIG_TPMFRONT struct { struct tpmfront_dev *dev; diff --git a/lib/sys.c b/lib/sys.c index 62c2020..2d48657 100644 --- a/lib/sys.c +++ b/lib/sys.c @@ -287,7 +287,7 @@ int read(int fd, void *buf, size_t nbytes) case FTYPE_FB: { int ret, n; n =3D nbytes / sizeof(union xenfb_in_event); - ret =3D fbfront_receive(files[fd].fb.dev, buf, n); + ret =3D fbfront_receive(files[fd].dev, buf, n); if (ret <=3D 0) { errno =3D EAGAIN; return -1; @@ -480,7 +480,7 @@ int close(int fd) #endif #ifdef CONFIG_FBFRONT case FTYPE_FB: - shutdown_fbfront(files[fd].fb.dev); + shutdown_fbfront(files[fd].dev); files[fd].type =3D FTYPE_NONE; return 0; #endif --=20 2.26.2 From nobody Thu Apr 25 15:04:29 2024 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=1641470309; cv=none; d=zohomail.com; s=zohoarc; b=Vgt+FGFjbr4QdKPHTHm6jNPu+jaT7xj3tKjAJmkm5KZSZM9/PxpVytWB9xV3aGEpeysRJX791ukVEcEkgV1qWx5Gz2dBYt40weuaa1WTqtrORL1QelxjxrtgNv6+NU6OGNtNQb9pDMVyM1yd56Cd9lFJ9khDq/1aPj83X7zMIMY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641470309; 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=pmQsTeEAO2F2JehoSUAYba8Y3ffpdoax96zqkTw3H6w=; b=AcxeUT9wA0kZBf/Gzn06ywZrO3AUDi/v1/pbV/3DwrRO9awEMszVlbJsdTSEcpHv4nEe+z2ODLGtrMO2gEBJd8zWsb7aHNBF/jBIbKz/3pu1P7Z98gofxgzp6P0NFmdqSZG7n8r05iVoTKkljzWx/74LY1JyInxSWcYM35XyMAE= 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 1641470309524222.38047261261715; Thu, 6 Jan 2022 03:58:29 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.253908.435223 (Exim 4.92) (envelope-from ) id 1n5RP7-0005Zh-0z; Thu, 06 Jan 2022 11:58:01 +0000 Received: by outflank-mailman (output) from mailman id 253908.435223; Thu, 06 Jan 2022 11:58:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RP6-0005Z6-NR; Thu, 06 Jan 2022 11:58:00 +0000 Received: by outflank-mailman (input) for mailman id 253908; Thu, 06 Jan 2022 11:57:59 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RP5-0005Uf-HV for xen-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:57:59 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e33f3c66-6ee7-11ec-9ce5-af14b9085ebd; 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-out2.suse.de (Postfix) with ESMTPS id EDC5B1F3A7; Thu, 6 Jan 2022 11:57:56 +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 C5E4E13C0D; Thu, 6 Jan 2022 11:57:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KPwkL0TZ1mHnJgAAMHmgww (envelope-from ); Thu, 06 Jan 2022 11:57:56 +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: e33f3c66-6ee7-11ec-9ce5-af14b9085ebd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641470276; 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=pmQsTeEAO2F2JehoSUAYba8Y3ffpdoax96zqkTw3H6w=; b=SIUb5DfRwcn7TS4qWmIGSdd7G6qhQ/XrhDETu7o7sN0SC7IQBPp4/22hBxBXw10PqAnY9h P28ZPsi+nfl6AnKztBteqgLZ1OlxkDu1UPeDHwIfmUXRKyVzq4DEpZSVD8r37fY872FJEg 7ywrBQ4TCoVf91mYmkMlD3GkklXXA7M= 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 09/15] mini-os: eliminate kbdfront union member in struct file Date: Thu, 6 Jan 2022 12:57:35 +0100 Message-Id: <20220106115741.3219-10-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: 1641470310725100004 Content-Type: text/plain; charset="utf-8" Replace the kbdfront specific union member in struct file with the common dev pointer. Signed-off-by: Juergen Gross Acked-by: Samuel Thibault Reviewed-by: Samuel Thibault --- fbfront.c | 2 +- include/lib.h | 3 --- lib/sys.c | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/fbfront.c b/fbfront.c index c8410af..1e055fb 100644 --- a/fbfront.c +++ b/fbfront.c @@ -302,7 +302,7 @@ int kbdfront_open(struct kbdfront_dev *dev) { dev->fd =3D alloc_fd(FTYPE_KBD); printk("kbd_open(%s) -> %d\n", dev->nodename, dev->fd); - files[dev->fd].kbd.dev =3D dev; + files[dev->fd].dev =3D dev; return dev->fd; } #endif diff --git a/include/lib.h b/include/lib.h index 2a9a01c..5201ed7 100644 --- a/include/lib.h +++ b/include/lib.h @@ -196,9 +196,6 @@ struct file { struct { struct netfront_dev *dev; } tap; - struct { - struct kbdfront_dev *dev; - } kbd; #ifdef CONFIG_TPMFRONT struct { struct tpmfront_dev *dev; diff --git a/lib/sys.c b/lib/sys.c index 2d48657..8c7ea3c 100644 --- a/lib/sys.c +++ b/lib/sys.c @@ -275,7 +275,7 @@ int read(int fd, void *buf, size_t nbytes) case FTYPE_KBD: { int ret, n; n =3D nbytes / sizeof(union xenkbd_in_event); - ret =3D kbdfront_receive(files[fd].kbd.dev, buf, n); + ret =3D kbdfront_receive(files[fd].dev, buf, n); if (ret <=3D 0) { errno =3D EAGAIN; return -1; @@ -474,7 +474,7 @@ int close(int fd) #endif #ifdef CONFIG_KBDFRONT case FTYPE_KBD: - shutdown_kbdfront(files[fd].kbd.dev); + shutdown_kbdfront(files[fd].dev); files[fd].type =3D FTYPE_NONE; return 0; #endif --=20 2.26.2 From nobody Thu Apr 25 15:04:29 2024 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=1641470312; cv=none; d=zohomail.com; s=zohoarc; b=FFg5e/fCH4SHC+JPJy3DXLBsYkg0AZEzO676C2Mmzk9ThDSeO3Ot2vyV96xMfp51CSXurwgGI/qhKxXSWJzs6camixsLfKqJSGArTaphSgodQ8M87HqBjW01cYHaKcJ2Z2R5H3CwQjQa5Ft3Qd+xyPY3779e5OYfwM+cWHsUxOc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641470312; 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=yL3iNqERg5EulNmJK0ycoAwzGvfibMXTv4Vh1zCFUho=; b=GJMZkKkzBmnui8qsBOhT+eDBn/MXncJ2vWQV/cokamHu2Ww/1Kodaj9kJRAoebbrJZVAF6iwOmoMVGzyFDoKbVirrNLtscvjkDLZ4dQLisXsYe8rjhRPH4j43ffa/dxngDiQUR21OENmzavukLSFyGV3bXsSyPJIeXzAFbiGjTs= 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 1641470312981793.0515462322711; Thu, 6 Jan 2022 03:58:32 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.253923.435325 (Exim 4.92) (envelope-from ) id 1n5RPG-0007f8-6D; Thu, 06 Jan 2022 11:58:10 +0000 Received: by outflank-mailman (output) from mailman id 253923.435325; Thu, 06 Jan 2022 11:58:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RPF-0007b4-7N; Thu, 06 Jan 2022 11:58:09 +0000 Received: by outflank-mailman (input) for mailman id 253923; Thu, 06 Jan 2022 11:58:07 +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 1n5RPC-0005UX-UF for xen-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:06 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e35b35a9-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-out2.suse.de (Postfix) with ESMTPS id 282E51F3A8; Thu, 6 Jan 2022 11:57:57 +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 F352113C0D; Thu, 6 Jan 2022 11:57:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wIYpOkTZ1mHnJgAAMHmgww (envelope-from ); Thu, 06 Jan 2022 11:57:56 +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: e35b35a9-6ee7-11ec-81c0-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641470277; 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=yL3iNqERg5EulNmJK0ycoAwzGvfibMXTv4Vh1zCFUho=; b=G76wKbbFM05FStujvf/bF/czASQ6aHupL7jeNQeVnlWOFrqYUzFmSDKosGJMmltnA/LJJ1 USaPHOqWwxFbc1FAgAlIiKlUdkyAmeCSIElV/7K0mSOEC9ssyWZDLzcz2jL3jI42sOvyY5 C6hJQLbxXyqk3OonxIsIRRrHpEQI2/0= 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 10/15] mini-os: eliminate netfront union member in struct file Date: Thu, 6 Jan 2022 12:57:36 +0100 Message-Id: <20220106115741.3219-11-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: 1641470314840100001 Content-Type: text/plain; charset="utf-8" Replace the netfront specific union member in struct file with the common dev pointer. Signed-off-by: Juergen Gross Acked-by: Samuel Thibault Reviewed-by: Samuel Thibault --- include/lib.h | 3 --- lib/sys.c | 6 +++--- netfront.c | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/include/lib.h b/include/lib.h index 5201ed7..f2a124e 100644 --- a/include/lib.h +++ b/include/lib.h @@ -193,9 +193,6 @@ struct file { struct evtchn_port_list ports; } evtchn; struct gntmap gntmap; - struct { - struct netfront_dev *dev; - } tap; #ifdef CONFIG_TPMFRONT struct { struct tpmfront_dev *dev; diff --git a/lib/sys.c b/lib/sys.c index 8c7ea3c..b35e433 100644 --- a/lib/sys.c +++ b/lib/sys.c @@ -263,7 +263,7 @@ int read(int fd, void *buf, size_t nbytes) #ifdef CONFIG_NETFRONT case FTYPE_TAP: { ssize_t ret; - ret =3D netfront_receive(files[fd].tap.dev, buf, nbytes); + ret =3D netfront_receive(files[fd].dev, buf, nbytes); if (ret <=3D 0) { errno =3D EAGAIN; return -1; @@ -339,7 +339,7 @@ int write(int fd, const void *buf, size_t nbytes) #endif #ifdef CONFIG_NETFRONT case FTYPE_TAP: - netfront_xmit(files[fd].tap.dev, (void*) buf, nbytes); + netfront_xmit(files[fd].dev, (void*) buf, nbytes); return nbytes; #endif #ifdef CONFIG_BLKFRONT @@ -450,7 +450,7 @@ int close(int fd) #endif #ifdef CONFIG_NETFRONT case FTYPE_TAP: - shutdown_netfront(files[fd].tap.dev); + shutdown_netfront(files[fd].dev); files[fd].type =3D FTYPE_NONE; return 0; #endif diff --git a/netfront.c b/netfront.c index a566e34..7696451 100644 --- a/netfront.c +++ b/netfront.c @@ -576,7 +576,7 @@ int netfront_tap_open(char *nodename) { } dev->fd =3D alloc_fd(FTYPE_TAP); printk("tap_open(%s) -> %d\n", nodename, dev->fd); - files[dev->fd].tap.dev =3D dev; + files[dev->fd].dev =3D dev; return dev->fd; } #endif --=20 2.26.2 From nobody Thu Apr 25 15:04:29 2024 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=1641470421; cv=none; d=zohomail.com; s=zohoarc; b=JgXJcIt2FaJGTO/snPaQM9/sS8+2m95fbifrkphy+W/xoE6r/Qm63gER+YSmBEJO3m/E8++V1vNmofozfItv3x4vxHsArW+0iuwyuliuLRFKuqg6tpI0+rx82yLdPBlb+LxQWKdkIlWXVjoQBJUY9kE3oTxqJ7NGNwdgFJtK/8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641470421; 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=zRc5gY/92MrOjMdEN5JMRpsapAMAJSL5mvFXRrg0SZ8=; b=hCnTPiTbiIldRzAOe+w1GyWaq/x2NschfoWhqlTuGvqABwJ39GMwz7f8W7U5Ymc4/w1tBWL4a7IfNfa4TkMsa5LUp88FLp+5gH2Q2H2uZ87YCfRfCxHu7/TrxL6cQSbtY5rdQxRWbX9iFpf0UwMclm5RnLPw13JiHMu/aJiS3K4= 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 1641470421629629.377319416322; Thu, 6 Jan 2022 04:00:21 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.253954.435400 (Exim 4.92) (envelope-from ) id 1n5RRC-0005r7-7M; Thu, 06 Jan 2022 12:00:10 +0000 Received: by outflank-mailman (output) from mailman id 253954.435400; Thu, 06 Jan 2022 12:00:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RRC-0005qy-3C; Thu, 06 Jan 2022 12:00:10 +0000 Received: by outflank-mailman (input) for mailman id 253954; Thu, 06 Jan 2022 12:00:08 +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 1n5RPK-0005UX-VB for xen-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:15 +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 e38fef9d-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 56DD521637; Thu, 6 Jan 2022 11:57:57 +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 2F50613C0D; Thu, 6 Jan 2022 11:57:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gJgyCkXZ1mHnJgAAMHmgww (envelope-from ); Thu, 06 Jan 2022 11:57:57 +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: e38fef9d-6ee7-11ec-81c0-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641470277; 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=zRc5gY/92MrOjMdEN5JMRpsapAMAJSL5mvFXRrg0SZ8=; b=EINi4iUrnmV02sZOkEQ0aY0MAvCbGsD2i1M+BL96gDxQk8ndjP1Ku7fAFaGucY5P7HstbD nGCSejiWKdhxXJAYAWY1ON+bV8q5+Xo6L7ThJLjeLIGtAE4z/tNkJTAzoO2pxzssh6mziG 1ssRJAkF0pweesDReQlfRaTtpuPCXmE= 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 11/15] mini-os: move tpm respgot member of struct file to device specific data Date: Thu, 6 Jan 2022 12:57:37 +0100 Message-Id: <20220106115741.3219-12-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: 1641470423869100001 Content-Type: text/plain; charset="utf-8" Tpmfront has a "respgot" flag in struct file, which can be moved to the device specific data. While at it make it a bool. The respgot flag of the tpm_tis member of struct file can be removed, as it is never read. Signed-off-by: Juergen Gross Acked-by: Samuel Thibault Reviewed-by: Samuel Thibault --- include/lib.h | 2 -- include/tpmfront.h | 2 ++ tpm_tis.c | 2 -- tpmfront.c | 10 +++++----- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/include/lib.h b/include/lib.h index f2a124e..d740065 100644 --- a/include/lib.h +++ b/include/lib.h @@ -196,13 +196,11 @@ struct file { #ifdef CONFIG_TPMFRONT struct { struct tpmfront_dev *dev; - int respgot; } tpmfront; #endif #ifdef CONFIG_TPM_TIS struct { struct tpm_chip *dev; - int respgot; } tpm_tis; #endif #ifdef CONFIG_XENBUS diff --git a/include/tpmfront.h b/include/tpmfront.h index c489fae..b7da50e 100644 --- a/include/tpmfront.h +++ b/include/tpmfront.h @@ -25,6 +25,7 @@ #ifndef TPMFRONT_H #define TPMFRONT_H =20 +#include #include #include #include @@ -53,6 +54,7 @@ struct tpmfront_dev { =20 #ifdef HAVE_LIBC int fd; + bool respgot; #endif =20 }; diff --git a/tpm_tis.c b/tpm_tis.c index 8a632b1..4127118 100644 --- a/tpm_tis.c +++ b/tpm_tis.c @@ -846,7 +846,6 @@ 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 false; - files[tpm->fd].tpm_tis.respgot =3D 0; files[tpm->fd].offset =3D 0; } #endif @@ -1290,7 +1289,6 @@ int tpm_tis_open(struct tpm_chip* tpm) tpm->fd =3D alloc_fd(FTYPE_TPM_TIS); printk("tpm_tis_open() -> %d\n", tpm->fd); files[tpm->fd].tpm_tis.dev =3D tpm; - files[tpm->fd].tpm_tis.respgot =3D 0; return tpm->fd; } =20 diff --git a/tpmfront.c b/tpmfront.c index 8b2a910..be671c2 100644 --- a/tpmfront.c +++ b/tpmfront.c @@ -439,8 +439,8 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8= _t* msg, size_t length) #ifdef HAVE_LIBC if(dev->fd >=3D 0) { files[dev->fd].read =3D false; - files[dev->fd].tpmfront.respgot =3D 0; files[dev->fd].offset =3D 0; + dev->respgot =3D false; } #endif wmb(); @@ -499,7 +499,7 @@ int i; #endif #ifdef HAVE_LIBC if(dev->fd >=3D 0) { - files[dev->fd].tpmfront.respgot =3D 1; + dev->respgot =3D true; } #endif quit: @@ -539,7 +539,7 @@ int tpmfront_open(struct tpmfront_dev* dev) dev->fd =3D alloc_fd(FTYPE_TPMFRONT); printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd); files[dev->fd].tpmfront.dev =3D dev; - files[dev->fd].tpmfront.respgot =3D 0; + dev->respgot =3D false; return dev->fd; } =20 @@ -580,7 +580,7 @@ int tpmfront_posix_read(int fd, uint8_t* buf, size_t co= unt) } =20 /* get the response if we haven't already */ - if(files[dev->fd].tpmfront.respgot =3D=3D 0) { + if (!dev->respgot) { if ((rc =3D tpmfront_recv(dev, &dummybuf, &dummysz)) !=3D 0) { errno =3D EIO; return -1; @@ -610,7 +610,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 && !files[dev->fd].tpmfront.res= pgot)) { + if(dev->waiting || (files[dev->fd].read && !dev->respgot)) { if ((rc =3D tpmfront_recv(dev, &dummybuf, &dummysz)) !=3D 0) { errno =3D EIO; return -1; --=20 2.26.2 From nobody Thu Apr 25 15:04:29 2024 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=1641470309; cv=none; d=zohomail.com; s=zohoarc; b=IXNwqEYrLfHtSGjNxwqemLRTWazZPj8uOKgeZDLgu20nI3x7v478GfmYlF4i3hvpl3WByU6SlT7FJHL2ycWZ8SmsO1JbXbw3r9B5S621O9vve4VmtL183AZLrSjN92Sx/d0bo1NiEr1CBAVqbT/KlU53Nce3kA+zyU9+HjBtJSU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641470309; 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=OlUsXgmJVXs1bcrolch8AFDDMEltM2NC+VAU9LgoD0k=; b=SXWnFHn+8I5BaoOnoJUhGxdKssu1oHfNWbTLi2JiuuKNY9+Hh+67VaGZhErcj9OkkkuEcuSmNQhnkIq3H/9dx17ts7pRdlNdanSqzT0OuK5ZhPHf6oxUUFnNboGSxIGJYuiVIhqkF4dxiq8lXamnOMHAcnzwNPijkXTXMh4B6+A= 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 1641470309587890.9162170125411; Thu, 6 Jan 2022 03:58:29 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.253918.435295 (Exim 4.92) (envelope-from ) id 1n5RPD-0007D2-1w; Thu, 06 Jan 2022 11:58:07 +0000 Received: by outflank-mailman (output) from mailman id 253918.435295; Thu, 06 Jan 2022 11:58:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RPC-0007CE-Rc; Thu, 06 Jan 2022 11:58:06 +0000 Received: by outflank-mailman (input) for mailman id 253918; Thu, 06 Jan 2022 11:58:04 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RPA-0005Uf-Hx for xen-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:04 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e3b29e51-6ee7-11ec-9ce5-af14b9085ebd; 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-out2.suse.de (Postfix) with ESMTPS id 848E31F3A9; Thu, 6 Jan 2022 11:57:57 +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 5D05713C0D; Thu, 6 Jan 2022 11:57:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UFlkFUXZ1mHnJgAAMHmgww (envelope-from ); Thu, 06 Jan 2022 11:57:57 +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: e3b29e51-6ee7-11ec-9ce5-af14b9085ebd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641470277; 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=OlUsXgmJVXs1bcrolch8AFDDMEltM2NC+VAU9LgoD0k=; b=lfHgdbJ6+meI0zCgqlYs1d1O3JM3OxV6m/IJ98l7HCddq4gKMv95J04jw6VHtAscXrHoLX QomAKyIBBAHOEqFzYEsSUk9GU/Ju7rEZ9dWchvkvyCDOqvQ073CobaOV4aQlduMxHyduQG kc4m6V9oqCFAeQGXoSwjiejWAfD6c6U= 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 12/15] mini-os: eliminate tpmfront union member in struct file Date: Thu, 6 Jan 2022 12:57:38 +0100 Message-Id: <20220106115741.3219-13-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: 1641470310735100006 Content-Type: text/plain; charset="utf-8" Replace the tpmfront specific union member in struct file with the common dev pointer. Signed-off-by: Juergen Gross Acked-by: Samuel Thibault Reviewed-by: Samuel Thibault --- include/lib.h | 5 ----- lib/sys.c | 2 +- tpmfront.c | 8 ++++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/include/lib.h b/include/lib.h index d740065..2ddc076 100644 --- a/include/lib.h +++ b/include/lib.h @@ -193,11 +193,6 @@ struct file { struct evtchn_port_list ports; } evtchn; struct gntmap gntmap; -#ifdef CONFIG_TPMFRONT - struct { - struct tpmfront_dev *dev; - } tpmfront; -#endif #ifdef CONFIG_TPM_TIS struct { struct tpm_chip *dev; diff --git a/lib/sys.c b/lib/sys.c index b35e433..b042bf5 100644 --- a/lib/sys.c +++ b/lib/sys.c @@ -462,7 +462,7 @@ int close(int fd) #endif #ifdef CONFIG_TPMFRONT case FTYPE_TPMFRONT: - shutdown_tpmfront(files[fd].tpmfront.dev); + shutdown_tpmfront(files[fd].dev); files[fd].type =3D FTYPE_NONE; return 0; #endif diff --git a/tpmfront.c b/tpmfront.c index be671c2..0a2fefc 100644 --- a/tpmfront.c +++ b/tpmfront.c @@ -538,7 +538,7 @@ int tpmfront_open(struct tpmfront_dev* dev) =20 dev->fd =3D alloc_fd(FTYPE_TPMFRONT); printk("tpmfront_open(%s) -> %d\n", dev->nodename, dev->fd); - files[dev->fd].tpmfront.dev =3D dev; + files[dev->fd].dev =3D dev; dev->respgot =3D false; return dev->fd; } @@ -547,7 +547,7 @@ int tpmfront_posix_write(int fd, const uint8_t* buf, si= ze_t count) { int rc; struct tpmfront_dev* dev; - dev =3D files[fd].tpmfront.dev; + dev =3D files[fd].dev; =20 if(count =3D=3D 0) { return 0; @@ -573,7 +573,7 @@ int tpmfront_posix_read(int fd, uint8_t* buf, size_t co= unt) size_t dummysz; struct tpmfront_dev* dev; =20 - dev =3D files[fd].tpmfront.dev; + dev =3D files[fd].dev; =20 if(count =3D=3D 0) { return 0; @@ -606,7 +606,7 @@ int tpmfront_posix_fstat(int fd, struct stat* buf) uint8_t* dummybuf; size_t dummysz; int rc; - struct tpmfront_dev* dev =3D files[fd].tpmfront.dev; + struct tpmfront_dev* dev =3D files[fd].dev; =20 /* If we have a response waiting, then read it now from the backend * so we can get its length*/ --=20 2.26.2 From nobody Thu Apr 25 15:04:29 2024 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=1641470472; cv=none; d=zohomail.com; s=zohoarc; b=Ys9rthgh1TmHUYsMqLx6TTWy96Q9iuNu0Yetrm4yAPcobz6E3h8WBKN/G5RywUmI6fcQ7Ao1fK4l++4v0wBIwy02n+a3wgHki+IJEAB1kkIa6CWYRuu04IiTHIRpHDMqJ3Femd4nNGiNDxYVhIn9ndu3yO35XwDKkw4E+UmcvDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641470472; 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=479+ZsaQ/HR1Ri0lahF7rot1Udcg9gaoznCeT0QqN9I=; b=WuCHvYHX4bs5rokjfBQzXSRjh0116BN/EwcbXd2zI/zkxNMmuO+nEwTA3hkygvINaduBTkzzz+APcpoGhj9F5pGZ/siQB1x0+IVTExhKWOURK36DBeDy/011kxI01LWnQ4tqdJZV68MCDG4WiecG9aTHlSxJKOvVl3XrNtzEdfw= 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 1641470472072864.7775303101458; Thu, 6 Jan 2022 04:01:12 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.253975.435441 (Exim 4.92) (envelope-from ) id 1n5RRv-0007nX-4e; Thu, 06 Jan 2022 12:00:55 +0000 Received: by outflank-mailman (output) from mailman id 253975.435441; Thu, 06 Jan 2022 12:00:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RRv-0007nQ-1F; Thu, 06 Jan 2022 12:00:55 +0000 Received: by outflank-mailman (input) for mailman id 253975; Thu, 06 Jan 2022 12:00:53 +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 1n5RPM-0005UX-VI for xen-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:16 +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 e3acd308-6ee7-11ec-81c0-a30af7de8005; Thu, 06 Jan 2022 12:57:58 +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 B0A17212C7; Thu, 6 Jan 2022 11:57:57 +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 89F2113C0D; Thu, 6 Jan 2022 11:57:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6MSCIEXZ1mHnJgAAMHmgww (envelope-from ); Thu, 06 Jan 2022 11:57:57 +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: e3acd308-6ee7-11ec-81c0-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641470277; 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=479+ZsaQ/HR1Ri0lahF7rot1Udcg9gaoznCeT0QqN9I=; b=fP1cCOY+bPvVqpVlay1gDfX8O7NpxJ+V8buwFGlupD4VRta30a8gBxfuW2lXra6O/GVt+e pCzOXGwBw69b5smW/dAVi5M7tLZhZnqyLla5hcIvKtzGf+KKc8LR+RbsGKk0FY9xQfmcFe f4HEdxeC+uV07G6NiofcCCeYE3k5TIQ= 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 13/15] mini-os: eliminate tpmtis union member in struct file Date: Thu, 6 Jan 2022 12:57:39 +0100 Message-Id: <20220106115741.3219-14-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: 1641470474249100001 Content-Type: text/plain; charset="utf-8" Replace the tpmtis specific union member in struct file with the common dev pointer. Signed-off-by: Juergen Gross Acked-by: Samuel Thibault Reviewed-by: Samuel Thibault --- include/lib.h | 5 ----- lib/sys.c | 2 +- tpm_tis.c | 8 ++++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/include/lib.h b/include/lib.h index 2ddc076..d6a29ba 100644 --- a/include/lib.h +++ b/include/lib.h @@ -193,11 +193,6 @@ struct file { struct evtchn_port_list ports; } evtchn; struct gntmap gntmap; -#ifdef CONFIG_TPM_TIS - struct { - struct tpm_chip *dev; - } tpm_tis; -#endif #ifdef CONFIG_XENBUS struct { /* To each xenbus FD is associated a queue of watch events for= this diff --git a/lib/sys.c b/lib/sys.c index b042bf5..96fc769 100644 --- a/lib/sys.c +++ b/lib/sys.c @@ -468,7 +468,7 @@ int close(int fd) #endif #ifdef CONFIG_TPM_TIS case FTYPE_TPM_TIS: - shutdown_tpm_tis(files[fd].tpm_tis.dev); + shutdown_tpm_tis(files[fd].dev); files[fd].type =3D FTYPE_NONE; return 0; #endif diff --git a/tpm_tis.c b/tpm_tis.c index 4127118..477f555 100644 --- a/tpm_tis.c +++ b/tpm_tis.c @@ -1288,14 +1288,14 @@ int tpm_tis_open(struct tpm_chip* tpm) =20 tpm->fd =3D alloc_fd(FTYPE_TPM_TIS); printk("tpm_tis_open() -> %d\n", tpm->fd); - files[tpm->fd].tpm_tis.dev =3D tpm; + files[tpm->fd].dev =3D tpm; return tpm->fd; } =20 int tpm_tis_posix_write(int fd, const uint8_t* buf, size_t count) { struct tpm_chip* tpm; - tpm =3D files[fd].tpm_tis.dev; + tpm =3D files[fd].dev; =20 if(tpm->locality < 0) { printk("tpm_tis_posix_write() failed! locality not set!\n"); @@ -1323,7 +1323,7 @@ int tpm_tis_posix_read(int fd, uint8_t* buf, size_t c= ount) { int rc; struct tpm_chip* tpm; - tpm =3D files[fd].tpm_tis.dev; + tpm =3D files[fd].dev; =20 if(count =3D=3D 0) { return 0; @@ -1350,7 +1350,7 @@ int tpm_tis_posix_read(int fd, uint8_t* buf, size_t c= ount) int tpm_tis_posix_fstat(int fd, struct stat* buf) { struct tpm_chip* tpm; - tpm =3D files[fd].tpm_tis.dev; + tpm =3D files[fd].dev; =20 buf->st_mode =3D O_RDWR; buf->st_uid =3D 0; --=20 2.26.2 From nobody Thu Apr 25 15:04:29 2024 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=1641470313; cv=none; d=zohomail.com; s=zohoarc; b=n0LLDejU5mCsRHuwowX0jk5EZeCD+9+eteS0dzhK9gPkWwpx/+IpOBVIAHSROU1efnG2guiMosIPILaXGzUBdc6eUn88KLwe1n6CxNiPiwxUn/Evj9LBauxfTmEiljX32etLIYRtDoztvY89g3vabUU/IChHPdQ1q1VOPsvCD4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641470313; 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=M5iLDQMfkH8htZ3wRFumo5FkHynp/HKlFIcfl/LfGDo=; b=Zra4Ko/1b/vwho7cIXmK+GdKgXrXENw+I2ZXbPy3IOIJqr4Zmi+2Uk9xLtNI7Sx9tJMmX5/XFjwhybT3rcscdEU4CmIT/+u0LCzDECnJOl2ppdKsWh2v2xxWSZIo4zsoIYJ5SMN03G/2kq/TNaFJ5bLAPVNxCosY1IklzYuhGFg= 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 1641470313237494.99882206711914; Thu, 6 Jan 2022 03:58:33 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.253924.435337 (Exim 4.92) (envelope-from ) id 1n5RPI-00083M-2G; Thu, 06 Jan 2022 11:58:12 +0000 Received: by outflank-mailman (output) from mailman id 253924.435337; Thu, 06 Jan 2022 11:58:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RPH-000814-2T; Thu, 06 Jan 2022 11:58:11 +0000 Received: by outflank-mailman (input) for mailman id 253924; Thu, 06 Jan 2022 11:58:08 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RPD-0005Uf-IO for xen-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:07 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e3c8adc9-6ee7-11ec-9ce5-af14b9085ebd; Thu, 06 Jan 2022 12:57:58 +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-out2.suse.de (Postfix) with ESMTPS id E0A1B1F39A; Thu, 6 Jan 2022 11:57:57 +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 B94E213C0D; Thu, 6 Jan 2022 11:57:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uKQXLEXZ1mHnJgAAMHmgww (envelope-from ); Thu, 06 Jan 2022 11:57:57 +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: e3c8adc9-6ee7-11ec-9ce5-af14b9085ebd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641470277; 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=M5iLDQMfkH8htZ3wRFumo5FkHynp/HKlFIcfl/LfGDo=; b=gh+DQlcESakDUkPTEJ1soZommb+igB4NL6JjGl9BJvgGVNIBS+t0hGxmsZzXWl5ejXlCDa r/HKGE594MTOyVJUoJU6atziAFjureSrxGbYvQ70Dyx4n6W5/nCfPX321J0E3+pHaBU9Hc ptRTDos2qr4ZF4LHh4aXkS2m1+1I2Sc= 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 14/15] mini-os: eliminate xenbus union member in struct file Date: Thu, 6 Jan 2022 12:57:40 +0100 Message-Id: <20220106115741.3219-15-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: 1641470314843100002 Content-Type: text/plain; charset="utf-8" Replace the xenbus specific union member in struct file with the common dev pointer. Signed-off-by: Juergen Gross Acked-by: Samuel Thibault Reviewed-by: Samuel Thibault --- include/lib.h | 7 ------- lib/sys.c | 2 +- lib/xs.c | 13 +++++++------ 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/include/lib.h b/include/lib.h index d6a29ba..91364ba 100644 --- a/include/lib.h +++ b/include/lib.h @@ -193,13 +193,6 @@ struct file { struct evtchn_port_list ports; } evtchn; struct gntmap gntmap; -#ifdef CONFIG_XENBUS - struct { - /* To each xenbus FD is associated a queue of watch events for= this - * FD. */ - xenbus_event_queue events; - } xenbus; -#endif }; }; =20 diff --git a/lib/sys.c b/lib/sys.c index 96fc769..6f2b026 100644 --- a/lib/sys.c +++ b/lib/sys.c @@ -776,7 +776,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_se= t *writefds, fd_set *exce #ifdef CONFIG_XENBUS case FTYPE_XENBUS: if (FD_ISSET(i, readfds)) { - if (files[i].xenbus.events) + if (files[i].dev) n++; else FD_CLR(i, readfds); diff --git a/lib/xs.c b/lib/xs.c index 324bd05..0459f52 100644 --- a/lib/xs.c +++ b/lib/xs.c @@ -21,8 +21,8 @@ static inline int _xs_fileno(struct xs_handle *h) { struct xs_handle *xs_daemon_open() { int fd =3D alloc_fd(FTYPE_XENBUS); - files[fd].xenbus.events =3D NULL; - printk("xs_daemon_open -> %d, %p\n", fd, &files[fd].xenbus.events); + files[fd].dev =3D NULL; + printk("xs_daemon_open -> %d, %p\n", fd, &files[fd].dev); return (void*)(intptr_t) fd; } =20 @@ -30,7 +30,7 @@ void xs_daemon_close(struct xs_handle *h) { int fd =3D _xs_fileno(h); struct xenbus_event *event, *next; - for (event =3D files[fd].xenbus.events; event; event =3D next) + for (event =3D files[fd].dev; event; event =3D next) { next =3D event->next; free(event); @@ -172,15 +172,16 @@ bool xs_watch(struct xs_handle *h, const char *path, = const char *token) { int fd =3D _xs_fileno(h); printk("xs_watch(%s, %s)\n", path, token); - return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token, &files[f= d].xenbus.events)); + return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token, + (xenbus_event_queue *)&files[fd].dev)); } =20 char **xs_read_watch(struct xs_handle *h, unsigned int *num) { int fd =3D _xs_fileno(h); struct xenbus_event *event; - event =3D files[fd].xenbus.events; - files[fd].xenbus.events =3D event->next; + event =3D files[fd].dev; + files[fd].dev =3D event->next; printk("xs_read_watch() -> %s %s\n", event->path, event->token); *num =3D 2; return (char **) &event->path; --=20 2.26.2 From nobody Thu Apr 25 15:04:29 2024 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=1641470450; cv=none; d=zohomail.com; s=zohoarc; b=ng2jPZzLsv7KSlh/RSVV2ZPPg7H75Acmur8GhsXiKJ0R64iQJOOLz+9N1dAIVJJCWZvE9VyzvFjj5lCsmvNPZQ1M//RWX7fZn2BmOQE1/pf+K3j18yzWRMJJgPeC1qDGUZGqCKnFCx+CWYifzABfKEzlqOTvJMCdmALbKYe4x8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641470450; 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=+GsFFIwit/Rt80w572ZQFBg1V74eYMuV1hjsub3Nyy0=; b=NWiEKfTMjeimUgiazdnfH8HUlyKWxWoMuEo1fGVnYlxpPtoho7wOxTatgrAZvLJWqCW6wmi3pmy1c09yiW8TEMKnLv6o2EnJ6A9JJ2Fxd3rimPJgIVPMMmlMPYaO6xESrKXucjVEKVrmWlNjl8egUTbY6dxeTwEUvMaQp0fqce8= 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 1641470450070397.3872658087215; Thu, 6 Jan 2022 04:00:50 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.253963.435419 (Exim 4.92) (envelope-from ) id 1n5RRc-0006mY-Ju; Thu, 06 Jan 2022 12:00:36 +0000 Received: by outflank-mailman (output) from mailman id 253963.435419; Thu, 06 Jan 2022 12:00:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n5RRc-0006mR-Gi; Thu, 06 Jan 2022 12:00:36 +0000 Received: by outflank-mailman (input) for mailman id 253963; Thu, 06 Jan 2022 12:00:34 +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 1n5RPO-0005UX-Vf for xen-devel@lists.xenproject.org; Thu, 06 Jan 2022 11:58:18 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e3e64e6f-6ee7-11ec-81c0-a30af7de8005; Thu, 06 Jan 2022 12:57:58 +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-out2.suse.de (Postfix) with ESMTPS id 188541F3A2; Thu, 6 Jan 2022 11:57:58 +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 E4F1D13C0D; Thu, 6 Jan 2022 11:57:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OCy1NkXZ1mHnJgAAMHmgww (envelope-from ); Thu, 06 Jan 2022 11:57:57 +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: e3e64e6f-6ee7-11ec-81c0-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641470278; 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=+GsFFIwit/Rt80w572ZQFBg1V74eYMuV1hjsub3Nyy0=; b=j/mDeu9UoOTfcQ/Pp6xXG3woMs+R3iP731Yk+OmKxmC5o4xgv83dcLoIqnL4xgZF/KUkzW 9lsqeKRBzTMviC0ajrCi4mO4MNc7tXWd9ZTMAMT9Wf38zyCnpyKxYdTNxs/ipBsp+j4eWv gMX/kIuCenCimRfwWjVkagf1Wrk9yHo= 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 15/15] mini-os: introduce get_file_from_fd() Date: Thu, 6 Jan 2022 12:57:41 +0100 Message-Id: <20220106115741.3219-16-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: 1641470453386100003 Content-Type: text/plain; charset="utf-8" Exporting the files[] array especially for components outside the mini-os source tree is limiting the ability to change any file handling in mini-os. Introduce a new function get_file_from_fd() to return the struct file pointer (or NULL) for a given file descriptor. Signed-off-by: Juergen Gross Acked-by: Samuel Thibault Reviewed-by: Samuel Thibault --- include/lib.h | 1 + lib/sys.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/include/lib.h b/include/lib.h index 91364ba..7a0546b 100644 --- a/include/lib.h +++ b/include/lib.h @@ -198,6 +198,7 @@ struct file { =20 extern struct file files[]; =20 +struct file *get_file_from_fd(int fd); int alloc_fd(enum fd_type type); void close_all_files(void); extern struct thread *main_thread; diff --git a/lib/sys.c b/lib/sys.c index 6f2b026..0e6fe5d 100644 --- a/lib/sys.c +++ b/lib/sys.c @@ -98,6 +98,14 @@ struct file files[NOFILE] =3D { { .type =3D FTYPE_CONSOLE }, /* stderr */ }; =20 +struct file *get_file_from_fd(int fd) +{ + if ( fd < 0 || fd >=3D NOFILE ) + return NULL; + + return (files[fd].type =3D=3D FTYPE_NONE) ? NULL : files + fd; +} + DECLARE_WAIT_QUEUE_HEAD(event_queue); =20 int alloc_fd(enum fd_type type) --=20 2.26.2