From nobody Thu Mar 28 09:46:58 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=1641913140; cv=none; d=zohomail.com; s=zohoarc; b=H1XjaEe+dKLFpOw328sI1J5Anmxh8feFniNwP71IOBvixd2uYa5F+I96+pIdpxv1EE2LTrM140/BCR53CSOyiMd7WMD7THBpOx3N4eRDVRZwyMG4qVZnnV3QwUbUOErT6cfG2JtvcFx3OrETdyc1Ul7B20sSzpvsfg0QBC9ct30= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641913140; 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=+t0vHow+1jfI7LN6o5B5LYduCmgQ0IacEYiredT7b+0=; b=Msmey2Q6ivIKx1HjssL2qHZr0TgwKmfdeCF0f1/acfPdxWxSPAhII7w2uoioBHAu3chYobfqhc5q7WOVsM6mG+002rGucaZHFTfL96al2YjJGH8AbRFnIiHs4ul+cXsGtxyegHmu1+2m/rchJCx+uaQvoW2JNVWbZ5dY3n8tBhA= 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 1641913140852447.27900179029245; Tue, 11 Jan 2022 06:59:00 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255764.438377 (Exim 4.92) (envelope-from ) id 1n7IbS-0002Py-2u; Tue, 11 Jan 2022 14:58:26 +0000 Received: by outflank-mailman (output) from mailman id 255764.438377; Tue, 11 Jan 2022 14:58:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n7IbR-0002PX-TL; Tue, 11 Jan 2022 14:58:25 +0000 Received: by outflank-mailman (input) for mailman id 255764; Tue, 11 Jan 2022 14:58:24 +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 1n7IbQ-0002Oa-CQ for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:24 +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 ea732dc8-72ee-11ec-9ce5-af14b9085ebd; Tue, 11 Jan 2022 15:58:22 +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 307611F3B1; Tue, 11 Jan 2022 14:58:20 +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 08E741403F; Tue, 11 Jan 2022 14:58:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SPr4AAyb3WH9eQAAMHmgww (envelope-from ); Tue, 11 Jan 2022 14:58:20 +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: ea732dc8-72ee-11ec-9ce5-af14b9085ebd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641913100; 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=+t0vHow+1jfI7LN6o5B5LYduCmgQ0IacEYiredT7b+0=; b=OGLo/N++S22CxpWwoigNm0n3vT4KfIh+MFOyER6HhCKV1FtpwitHHHzo+gmfes2bV425cz GLU3ADO3UMjXdJPokxOSOt1R7tOwm5JmnGoIBcGvDwirbibYOJz5laz4dMPqFs+3AuXmjn MhsqXMzy2J0gEG06o26qYSJFajXVNR8= 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 v2 01/18] mini-os: split struct file definition from its usage Date: Tue, 11 Jan 2022 15:58:00 +0100 Message-Id: <20220111145817.22170-2-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220111145817.22170-1-jgross@suse.com> References: <20220111145817.22170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641913141646100006 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 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 Mar 28 09:46:58 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=1641913753; cv=none; d=zohomail.com; s=zohoarc; b=lp1t7P4kDwldC1VS5XX0iNsI1gf+3BPJoaBNsC7SYqdjdsB0mA5M5Fe+7nJjKtV/EfNIhMoGS1uCCz2LgaI2hceRfX2v6VR71oJmtdMZY5vJyDkR4L2sA5s7y+MJlNp06YlhIR6cwvuVPIzMa3tJhW6hJsACHXGDU4KkCG+EAxQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641913753; 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=vzZzmPAjeVTU9pmfwYUWWND13ROdq/Dkiqf1Bikl8LY=; b=i+Z4D9e0KNXEv1tPFi8whCOwtByUdVAas8awB963Z33r+mhWeHvyNs9PKNtzg8YOUXgrsBHkLT6aERQ2WkRzFT6JnVMLSr0/8DtxjTl2+zICStLQtZtnVcZqF8Ep0/X3Sy8Fe5HR9igeOKNCV3BzU27fQKGWG6fvhkBmpBYh7FY= 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 1641913753087980.4043593834542; Tue, 11 Jan 2022 07:09:13 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255828.438618 (Exim 4.92) (envelope-from ) id 1n7Ile-0005yT-Mi; Tue, 11 Jan 2022 15:08:58 +0000 Received: by outflank-mailman (output) from mailman id 255828.438618; Tue, 11 Jan 2022 15:08:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n7Ile-0005yM-Ie; Tue, 11 Jan 2022 15:08:58 +0000 Received: by outflank-mailman (input) for mailman id 255828; Tue, 11 Jan 2022 15:08:57 +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 1n7Iba-0002Oa-DQ for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:34 +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 ea895f7d-72ee-11ec-9ce5-af14b9085ebd; Tue, 11 Jan 2022 15:58:22 +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 5D9031F3B9; Tue, 11 Jan 2022 14:58:20 +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 3681613DDD; Tue, 11 Jan 2022 14:58:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AJUxDAyb3WH9eQAAMHmgww (envelope-from ); Tue, 11 Jan 2022 14:58:20 +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: ea895f7d-72ee-11ec-9ce5-af14b9085ebd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641913100; 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=vzZzmPAjeVTU9pmfwYUWWND13ROdq/Dkiqf1Bikl8LY=; b=CQ7U6vS/PPESmcmYahKPhyhfyfDP9ZdiGATPqxGYb8u8pYMiD9FR3EZ70b2H41lPOyDFFt yHK1EnEMmR/k7RQQqVThpgoBFsBu9iLjCIq2UmPU2gfy/Qi42ajnUJDzm9vlT2XUCpfMtd V/RiFJrKrzqNiKcye5i6wKu2DkgQiwQ= 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 v2 02/18] mini-os: makes file.read bool and move it ahead of device specific part Date: Tue, 11 Jan 2022 15:58:01 +0100 Message-Id: <20220111145817.22170-3-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220111145817.22170-1-jgross@suse.com> References: <20220111145817.22170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641913753630100001 Content-Type: text/plain; charset="utf-8" The read member of struct file should be bool. In order to have the device specific part at the end of the structure move "read" ahead of that. Signed-off-by: Juergen Gross Reviewed-by: Samuel Thibault --- blkfront.c | 4 ++-- console/xencons_ring.c | 2 +- fbfront.c | 12 ++++++------ include/lib.h | 3 ++- netfront.c | 4 ++-- tpm_tis.c | 2 +- tpmfront.c | 6 +++--- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/blkfront.c b/blkfront.c index 834a978..7c8eb74 100644 --- a/blkfront.c +++ b/blkfront.c @@ -62,7 +62,7 @@ void blkfront_handler(evtchn_port_t port, struct pt_regs = *regs, void *data) int fd =3D dev->fd; =20 if (fd !=3D -1) - files[fd].read =3D 1; + files[fd].read =3D true; #endif wake_up(&blkfront_queue); } @@ -484,7 +484,7 @@ int blkfront_aio_poll(struct blkfront_dev *dev) moretodo: #ifdef HAVE_LIBC if (dev->fd !=3D -1) { - files[dev->fd].read =3D 0; + files[dev->fd].read =3D false; mb(); /* Make sure to let the handler set read to 1 before we star= t looking at the ring */ } #endif diff --git a/console/xencons_ring.c b/console/xencons_ring.c index b6db74e..c348f3c 100644 --- a/console/xencons_ring.c +++ b/console/xencons_ring.c @@ -102,7 +102,7 @@ void console_handle_input(evtchn_port_t port, struct pt= _regs *regs, void *data) int fd =3D dev ? dev->fd : -1; =20 if (fd !=3D -1) - files[fd].read =3D 1; + files[fd].read =3D true; =20 wake_up(&console_queue); #else diff --git a/fbfront.c b/fbfront.c index d3b3848..6725da1 100644 --- a/fbfront.c +++ b/fbfront.c @@ -45,7 +45,7 @@ void kbdfront_handler(evtchn_port_t port, struct pt_regs = *regs, void *data) int fd =3D dev->fd; =20 if (fd !=3D -1) - files[fd].read =3D 1; + files[fd].read =3D true; #endif wake_up(&kbdfront_queue); } @@ -207,7 +207,7 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xe= nkbd_in_event *buf, int n =20 #ifdef HAVE_LIBC if (dev->fd !=3D -1) { - files[dev->fd].read =3D 0; + files[dev->fd].read =3D false; mb(); /* Make sure to let the handler set read to 1 before we star= t looking at the ring */ } #endif @@ -229,7 +229,7 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xe= nkbd_in_event *buf, int n #ifdef HAVE_LIBC if (cons !=3D prod && dev->fd !=3D -1) /* still some events to read */ - files[dev->fd].read =3D 1; + files[dev->fd].read =3D true; #endif =20 return i; @@ -349,7 +349,7 @@ void fbfront_handler(evtchn_port_t port, struct pt_regs= *regs, void *data) int fd =3D dev->fd; =20 if (fd !=3D -1) - files[fd].read =3D 1; + files[fd].read =3D true; #endif wake_up(&fbfront_queue); } @@ -376,7 +376,7 @@ int fbfront_receive(struct fbfront_dev *dev, union xenf= b_in_event *buf, int n) =20 #ifdef HAVE_LIBC if (dev->fd !=3D -1) { - files[dev->fd].read =3D 0; + files[dev->fd].read =3D false; mb(); /* Make sure to let the handler set read to 1 before we star= t looking at the ring */ } #endif @@ -398,7 +398,7 @@ int fbfront_receive(struct fbfront_dev *dev, union xenf= b_in_event *buf, int n) #ifdef HAVE_LIBC if (cons !=3D prod && dev->fd !=3D -1) /* still some events to read */ - files[dev->fd].read =3D 1; + files[dev->fd].read =3D true; #endif =20 return i; diff --git a/include/lib.h b/include/lib.h index a638bc9..df2de9e 100644 --- a/include/lib.h +++ b/include/lib.h @@ -49,6 +49,7 @@ #define _LIB_H_ =20 #include +#include #include #include #include @@ -183,6 +184,7 @@ struct evtchn_port_info { =20 struct file { enum fd_type type; + bool read; /* maybe available for read */ union { struct { /* lwIP fd */ @@ -235,7 +237,6 @@ struct file { } xenbus; #endif }; - int read; /* maybe available for read */ }; =20 extern struct file files[]; diff --git a/netfront.c b/netfront.c index dfe065b..a566e34 100644 --- a/netfront.c +++ b/netfront.c @@ -255,7 +255,7 @@ void netfront_select_handler(evtchn_port_t port, struct= pt_regs *regs, void *dat local_irq_restore(flags); =20 if (fd !=3D -1) - files[fd].read =3D 1; + files[fd].read =3D true; wake_up(&netfront_queue); } #endif @@ -783,7 +783,7 @@ ssize_t netfront_receive(struct netfront_dev *dev, unsi= gned char *data, size_t l network_rx(dev); if (!dev->rlen && fd !=3D -1) /* No data for us, make select stop returning */ - files[fd].read =3D 0; + files[fd].read =3D false; /* Before re-enabling the interrupts, in case a packet just arrived in= the * meanwhile. */ local_irq_restore(flags); diff --git a/tpm_tis.c b/tpm_tis.c index 475ac5d..4a51027 100644 --- a/tpm_tis.c +++ b/tpm_tis.c @@ -845,7 +845,7 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, si= ze_t len) { } #ifdef HAVE_LIBC if(tpm->fd >=3D 0) { - files[tpm->fd].read =3D 0; + files[tpm->fd].read =3D false; files[tpm->fd].tpm_tis.respgot =3D 0; files[tpm->fd].tpm_tis.offset =3D 0; } diff --git a/tpmfront.c b/tpmfront.c index 6049244..d825b49 100644 --- a/tpmfront.c +++ b/tpmfront.c @@ -66,7 +66,7 @@ void tpmfront_handler(evtchn_port_t port, struct pt_regs = *regs, void *data) { dev->waiting =3D 0; #ifdef HAVE_LIBC if(dev->fd >=3D 0) { - files[dev->fd].read =3D 1; + files[dev->fd].read =3D true; } #endif wake_up(&dev->waitq); @@ -438,7 +438,7 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8= _t* msg, size_t length) dev->resplen =3D 0; #ifdef HAVE_LIBC if(dev->fd >=3D 0) { - files[dev->fd].read =3D 0; + files[dev->fd].read =3D false; files[dev->fd].tpmfront.respgot =3D 0; files[dev->fd].tpmfront.offset =3D 0; } @@ -611,7 +611,7 @@ int tpmfront_posix_fstat(int fd, struct stat* buf) =20 /* If we have a response waiting, then read it now from the backend * so we can get its length*/ - if(dev->waiting || (files[dev->fd].read =3D=3D 1 && !files[dev->fd].tpm= front.respgot)) { + if(dev->waiting || (files[dev->fd].read && !files[dev->fd].tpmfront.res= pgot)) { if ((rc =3D tpmfront_recv(dev, &dummybuf, &dummysz)) !=3D 0) { errno =3D EIO; return -1; --=20 2.26.2 From nobody Thu Mar 28 09:46:58 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=1641913141; cv=none; d=zohomail.com; s=zohoarc; b=Z4s0KLAJctb35Te3jCKdZM10u0slLy5l6j4TSOAqXbEpHyG7zZDAL3D5XXyKSg64oLG4k7UexboBrrDsINZEr9hx0CqFOApBhPt3CCCYPwbs/GTZL4VQK7gfXWIf3+JzrIfcohUr4pcMHtrwF/uBrSoEAgGYQPryl7fkeS8bnAY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641913141; 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=B1qIgvUq07hNrHG3qYVz9ZnwoNPkdqDFYkWrq9AIUhQ=; b=kErkP1ZSzkLe5ZvhFsrm5Xx3KWXykm+k/CtjEo6m7BhWjkeEcgsjvwl00m4+jDCA/ZU2caX++BMldqHy5hNGrfUQOT5KcVhtZ2NXkhs9PDocJTeR2r/jU0Lvzz8CgfqFXUHRZo1o5CzxeACws/H1HlX7wV+QgbJUcsAE/LpHSv8= 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 1641913141879121.61120877564554; Tue, 11 Jan 2022 06:59:01 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255781.438497 (Exim 4.92) (envelope-from ) id 1n7Ibd-0004un-Fo; Tue, 11 Jan 2022 14:58:37 +0000 Received: by outflank-mailman (output) from mailman id 255781.438497; Tue, 11 Jan 2022 14:58:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n7Ibc-0004qm-KJ; Tue, 11 Jan 2022 14:58:36 +0000 Received: by outflank-mailman (input) for mailman id 255781; Tue, 11 Jan 2022 14:58:32 +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 1n7IbY-0002Oa-DR for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:32 +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 eaa6c309-72ee-11ec-9ce5-af14b9085ebd; Tue, 11 Jan 2022 15:58:22 +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 8B1AB212C5; Tue, 11 Jan 2022 14:58:20 +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 63AD313DDD; Tue, 11 Jan 2022 14:58:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mNItFwyb3WH9eQAAMHmgww (envelope-from ); Tue, 11 Jan 2022 14:58:20 +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: eaa6c309-72ee-11ec-9ce5-af14b9085ebd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641913100; 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=B1qIgvUq07hNrHG3qYVz9ZnwoNPkdqDFYkWrq9AIUhQ=; b=Hm+0JCHE/qFCO0PSAk6d7BkNGhNjVFHbFcBonMcRxLYHDPJf9AuEnTDIGW4d+8Glr7g2hn FH4Z2mIWkoOvxwp8LcedDRrPQeaej4OqKw+A/bVxTpdFbfenwQqcizECq/SLYRMGHXyC19 lFAXftWBn3Ac8Cic1GjyT3P3igyPKVk= 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 v2 03/18] mini-os: make offset a common struct file member for all types Date: Tue, 11 Jan 2022 15:58:02 +0100 Message-Id: <20220111145817.22170-4-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220111145817.22170-1-jgross@suse.com> References: <20220111145817.22170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641913143942100001 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 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 Mar 28 09:46:58 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=1641913142; cv=none; d=zohomail.com; s=zohoarc; b=Kaalrr+arvpnLZwq4wJ/GT3eiG6kMJTUGx46OAgXQkSO9khq3TiRONlCfCYu78c9KpDCFDmKY4oBztn+uG3e5U1u+0jLxvuxbDUm81JFLTlpJVLIc9vKyf6fj9XVqNw/UcQ11fhDtTnoziYiiR1XI6P7EBW2us+jQARU8J29SEE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641913142; 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=DMMBPYWRjtz4/x5ruR8HIV8cwX5HYWaCHB+pYDCnRVA=; b=HMCyCxX8c+vzN9z+CkVwcsZK/MGECQQPje1FMQVhX/r4p/5VzArYV679+1VfXI6wT+v/VIku75SZy1gYyB+9DXvkjzgO9B7gzdk0Vy5S5qHK0QDGLl7pusDq9SoIZBgRZ5awyFe3rjDBwlyK0327SxnQwWEcl1i/KdlvIFYulXg= 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 164191314210577.06509157836763; Tue, 11 Jan 2022 06:59:02 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255776.438464 (Exim 4.92) (envelope-from ) id 1n7IbZ-000468-Ma; Tue, 11 Jan 2022 14:58:33 +0000 Received: by outflank-mailman (output) from mailman id 255776.438464; Tue, 11 Jan 2022 14:58:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n7IbZ-00042H-5n; Tue, 11 Jan 2022 14:58:33 +0000 Received: by outflank-mailman (input) for mailman id 255776; Tue, 11 Jan 2022 14:58:30 +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 1n7IbW-0002OZ-DN for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:30 +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 eabddecc-72ee-11ec-81c1-a30af7de8005; Tue, 11 Jan 2022 15:58:22 +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 B8B941F3BA; Tue, 11 Jan 2022 14:58:20 +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 90B4913DDD; Tue, 11 Jan 2022 14:58:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YLshIgyb3WH9eQAAMHmgww (envelope-from ); Tue, 11 Jan 2022 14:58:20 +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: eabddecc-72ee-11ec-81c1-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641913100; 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=DMMBPYWRjtz4/x5ruR8HIV8cwX5HYWaCHB+pYDCnRVA=; b=JzdJyIpda3v4DRJ6dS3sevj+AMPFI4kl5bVC6hqBjKmi/wVNJD011RpzoX3nC6Wow99h/x abJGpEd/063Sn404YSrpDDbM34VQl0OcQOOvrZrKpVyM5NMvV9IkhKmt972sFvCU31b+Ce tIjGmAXz8jLlE4wy673TLMcZqma+nX8= 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 v2 04/18] mini-os: replace multiple fd elements in struct file by common one Date: Tue, 11 Jan 2022 15:58:03 +0100 Message-Id: <20220111145817.22170-5-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220111145817.22170-1-jgross@suse.com> References: <20220111145817.22170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641913143981100002 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 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 Mar 28 09:46:58 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=1641913142; cv=none; d=zohomail.com; s=zohoarc; b=H4UJZsC+rjPQquKA8jXk5s/kfp3riwnBW+nJNoXPq4pd8De2DJKAado5ArZ/l854DPtvrlIMWW/j2FvXZ/aKwUz5UDUo/ZfgJLIuNhb8F1MX/gVb8BfSE7Rxsq1MO0JaYR4FueDQvUzMapW8TPVSc6Pw588V/8KjtB92zGJihpU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641913142; 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=bXQLf+XZM4DSdC0ST175q8yp6sLq3mgUD+Ukh4h4ycY=; b=QO6xvE1sHI/GnElRMOMzo2tmvyTjPKSv19Yoq8R77o7xn88387ZULPew/GBRIiRcRBmIV8pgEoCp/Zc3FRJFuKpwPm8xAeq2jik0hEhRcZdpAlmietOWycjOC2yY+78rCR4VAPM55PABz3wjgvRdm+l4q1WWSC8yVsiJr1G4Ug4= 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 16419131425323.7278336188801404; Tue, 11 Jan 2022 06:59:02 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255763.438386 (Exim 4.92) (envelope-from ) id 1n7IbS-0002WI-Ew; Tue, 11 Jan 2022 14:58:26 +0000 Received: by outflank-mailman (output) from mailman id 255763.438386; Tue, 11 Jan 2022 14:58:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n7IbS-0002VX-7Z; Tue, 11 Jan 2022 14:58:26 +0000 Received: by outflank-mailman (input) for mailman id 255763; Tue, 11 Jan 2022 14:58:24 +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 1n7IbQ-0002OZ-CJ for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:24 +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 eae6e135-72ee-11ec-81c1-a30af7de8005; Tue, 11 Jan 2022 15:58:22 +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 F1D5A1F3BB; Tue, 11 Jan 2022 14:58:20 +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 BEF7D13DDD; Tue, 11 Jan 2022 14:58:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iPVtLQyb3WH9eQAAMHmgww (envelope-from ); Tue, 11 Jan 2022 14:58:20 +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: eae6e135-72ee-11ec-81c1-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641913100; 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=bXQLf+XZM4DSdC0ST175q8yp6sLq3mgUD+Ukh4h4ycY=; b=uo+Ej/mLxhV+wD9G0M/07AtRWmY/ziB4vZFuM4UjznOccjblD0NKqbjdhR7PaUhIu46N2w uCSwSIv3JpiHCPmX+mQitsPCQYAlODzC8u7T1VYDwvWZ+SN1hzrsJPN0L+SYivvl3y8VOz gIhCyXUdpfgBdjM+gutQGZFr/MluhKI= 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 v2 05/18] mini-os: introduce a common dev pointer in struct file Date: Tue, 11 Jan 2022 15:58:04 +0100 Message-Id: <20220111145817.22170-6-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220111145817.22170-1-jgross@suse.com> References: <20220111145817.22170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641913144040100003 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 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 Mar 28 09:46:58 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=1641913143; cv=none; d=zohomail.com; s=zohoarc; b=V7Cd0g6uz+QZ5f0lbkRysRJOcsPy1MOdsGmUu1rXzM37DfSi0VnBT7b2a/7WvSrV3NjtOVUZzwRvdidyAks0/F7SpO7IsnzxFs2ekrvuinHup1VpKmHHTpwn2ArNk9VlzMmC367eUu7gMOke8zP+aAznLsK77MINFt3QXRVDxTs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641913143; 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=cpZ+5J0dnLWZk57QHjN9YUOxVha4rvn1wsE3TtHogLs=; b=jRrXqjlcc11CujUYUA+plMSk7hSJe/iGMgTGC+qQaWz6RKWSHHVvCy333zyiB71hQG38+lyyZlYYSwvQjAMZYjed6R7RoE9+L7W2kKuCj2uoWQGNLiFk+oZ3ErWiLLl/wB4y7J+z+gORiWT2AmXkOgZ5Gd3y5XV4KSZT+PlBnA8= 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 164191314338534.125481345326534; Tue, 11 Jan 2022 06:59:03 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255767.438415 (Exim 4.92) (envelope-from ) id 1n7IbU-00033p-Ad; Tue, 11 Jan 2022 14:58:28 +0000 Received: by outflank-mailman (output) from mailman id 255767.438415; Tue, 11 Jan 2022 14:58:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n7IbT-00031s-W5; Tue, 11 Jan 2022 14:58:27 +0000 Received: by outflank-mailman (input) for mailman id 255767; Tue, 11 Jan 2022 14:58:26 +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 1n7IbS-0002Oa-Ct for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:26 +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 eb068b7d-72ee-11ec-9ce5-af14b9085ebd; Tue, 11 Jan 2022 15:58:22 +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 2BE751F3BC; Tue, 11 Jan 2022 14:58:21 +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 0484A13DDD; Tue, 11 Jan 2022 14:58:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8NN9Owyb3WH9eQAAMHmgww (envelope-from ); Tue, 11 Jan 2022 14:58:20 +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: eb068b7d-72ee-11ec-9ce5-af14b9085ebd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641913101; 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=cpZ+5J0dnLWZk57QHjN9YUOxVha4rvn1wsE3TtHogLs=; b=GgsG7/fulZvIDHuEMcqegNiYNkq/fIzKJ14c9i1ZyEujrgF7ivH9zajgC+1sYzo67tNkVC z5tBQ66e1EP45KeW2YHCgLaTT81ormHlyMXeQ0cNwZxwQmKjPRsnP+Q4GRR7br7XsJeoZl dCHr125Rm95Gx36yZl+/4hhKPiPJTQc= 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 v2 06/18] mini-os: eliminate blkfront union member in struct file Date: Tue, 11 Jan 2022 15:58:05 +0100 Message-Id: <20220111145817.22170-7-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220111145817.22170-1-jgross@suse.com> References: <20220111145817.22170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641913144381100008 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 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 Mar 28 09:46:58 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=1641913143; cv=none; d=zohomail.com; s=zohoarc; b=ce8C/IkJutoN3ip3pw5HUtT4bg1AFyHX1JQbkvvAzXac/vYlWZ8jA1BDZphMwH65sSqYDE0tXSnHC+VKp47oGefB2rnni/RbgMXCdifREp//YUe+d1E4UsJM+afEN7zRETcwjJpfJyYiWa3NvewbbFx4+Q0Y6KPTI3tZvA01JAQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641913143; 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=+xnAEQMivwL4xL9yiMr125JOzBgLed0TX8eG+d+rWgM=; b=RheFBub+njUXRtuRkMFenw+eD91Dc0KqtLkgDr8j3uTlMj2CQxI548sOEqmyl+Uz4wY5zcQ1W+yI5NcqRqXW0DvQC6IkdzOnWdtCSZQIoUVM0Gur4NLa8au5igHtBHi6dPE4pEqmYTh9FGJu71SnNGkrYk2C0BlsR7vInbfUZmA= 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 1641913143391217.57886937178023; Tue, 11 Jan 2022 06:59:03 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255771.438444 (Exim 4.92) (envelope-from ) id 1n7IbX-0003k1-GF; Tue, 11 Jan 2022 14:58:31 +0000 Received: by outflank-mailman (output) from mailman id 255771.438444; Tue, 11 Jan 2022 14:58:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n7IbX-0003iM-4x; Tue, 11 Jan 2022 14:58:31 +0000 Received: by outflank-mailman (input) for mailman id 255771; Tue, 11 Jan 2022 14:58:28 +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 1n7IbU-0002Oa-Cs for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:28 +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 eb21f76e-72ee-11ec-9ce5-af14b9085ebd; Tue, 11 Jan 2022 15:58:22 +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 5C3C8212C9; Tue, 11 Jan 2022 14:58:21 +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 31DD213DDD; Tue, 11 Jan 2022 14:58:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kN/9Cg2b3WH9eQAAMHmgww (envelope-from ); Tue, 11 Jan 2022 14:58:21 +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: eb21f76e-72ee-11ec-9ce5-af14b9085ebd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641913101; 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=+xnAEQMivwL4xL9yiMr125JOzBgLed0TX8eG+d+rWgM=; b=R/45p93GSeJMhztoEblmNbeURw2Jd3i2M59SMmUr9L5QQZte6tY/E0Z8grVdSp9wexDUMw TP0HcQa9WBa/HfMYQNuU9pZltF2FEFkQzOYBeteIUQ2dCE21n5q5T+W9hmiMbg5JpHb2pT SFRKXp0LflJIK2ZWYuu5sPTGJWUifTI= 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 v2 07/18] mini-os: eliminate consfront union member in struct file Date: Tue, 11 Jan 2022 15:58:06 +0100 Message-Id: <20220111145817.22170-8-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220111145817.22170-1-jgross@suse.com> References: <20220111145817.22170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641913144367100007 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 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 Mar 28 09:46:58 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=1641913799; cv=none; d=zohomail.com; s=zohoarc; b=jQp2nYpXDpIXAtP1vXaqIvfSnzUcT40JDQAhWHEMX4WCj8cNv7OT6qwtAQQFh689M/663ZYCE+E3COkyjM8lHjl3x6fFRj6MmmMNMQy0LT2KM6skw+ZfdCnThh4JYvsOQm5goi833uaT3ACzxOJMSqAuYS8uJZMC2xcZroAEBH8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641913799; 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=TCkN47zI3SYm+mHMLDmij+4Y00VWhhcxxyZlFlzzdgc=; b=LKEAo0pKr+naWr+wfhLJWM8YNYLoXqzgLOCglacuwRd4uVCQ3GCM3MDO5s6uTh5zB+E5ire5kbXIwG9bScRZ8mhb8WwkwF0/gD2GSVV8oRnObvkHMKrE0HMVTNllBUNLaZ8t+6y7FGemdSmTBfg5BHfDRUYxwUFGy5QXeNcgFtY= 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 1641913799139338.44371890001287; Tue, 11 Jan 2022 07:09:59 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255845.438674 (Exim 4.92) (envelope-from ) id 1n7ImQ-0007qc-1W; Tue, 11 Jan 2022 15:09:46 +0000 Received: by outflank-mailman (output) from mailman id 255845.438674; Tue, 11 Jan 2022 15:09:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n7ImP-0007pl-R3; Tue, 11 Jan 2022 15:09:45 +0000 Received: by outflank-mailman (input) for mailman id 255845; Tue, 11 Jan 2022 15:09:44 +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 1n7Ibc-0002Oa-Dd for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:36 +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 ec17fb13-72ee-11ec-9ce5-af14b9085ebd; Tue, 11 Jan 2022 15:58:23 +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 8B8721F3BF; Tue, 11 Jan 2022 14:58:21 +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 60D931403F; Tue, 11 Jan 2022 14:58:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cCpeFg2b3WH9eQAAMHmgww (envelope-from ); Tue, 11 Jan 2022 14:58:21 +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: ec17fb13-72ee-11ec-9ce5-af14b9085ebd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641913101; 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=TCkN47zI3SYm+mHMLDmij+4Y00VWhhcxxyZlFlzzdgc=; b=OUTHaG7Za4OLcRVER+k9rsHzA3tJlldnWMM3DF4J9ecUKfFu3136R9mIRg4FghLkU13SvK uzc8EpFlxNG/8ZCXTvffr6d1eGq/uWfwpHHKPTcQLAuUO/910sYhoQSv4j9XwZ5PKLNP7i LfwrwgrT9OKljA6xK+yV5nNXDk3W3WA= 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 v2 08/18] mini-os: eliminate fbfront union member in struct file Date: Tue, 11 Jan 2022 15:58:07 +0100 Message-Id: <20220111145817.22170-9-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220111145817.22170-1-jgross@suse.com> References: <20220111145817.22170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641913800873100003 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 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 Mar 28 09:46:58 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=1641913140; cv=none; d=zohomail.com; s=zohoarc; b=ZT7K8tLIxQbBOUaY5ByCAqwi8X5jNWOPElTyg2+KxtAEJ4w8zJK4C4JS7pNaeXX9mU2iCSyoO9FjYqlM6rUmDlQu6We7UA2+DoUOZLOOKHffjMhsdcbboKHaWUMTYzZ1cA5oHFbV5nAhbHvRqfR6QE5e/I0hUA0zxuZjlZ9xKKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641913140; 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=Y+cFyyKrZNtwGa8ajfw3LoYs6PEvCSgNiRQOqaGYZOo=; b=A/UL1apXzfhiySEwaiOsVmAY1YdLZKVlT1gYCzIeoig2oUcgom5AnSA1abQYN57tvJIXwK886HvmlaEBNsAKvTHGIZtA/+mc0ZnqK4wIy5BPBHgXeUspJbcO/zUjKcjBRceC4GlrDqXutBg43wdQ3M7XcgBP7mY4QLjH47dI7P8= 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 1641913140834552.532926939051; Tue, 11 Jan 2022 06:59:00 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255780.438489 (Exim 4.92) (envelope-from ) id 1n7Ibc-0004eG-81; Tue, 11 Jan 2022 14:58:36 +0000 Received: by outflank-mailman (output) from mailman id 255780.438489; Tue, 11 Jan 2022 14:58: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 1n7Ibb-0004bW-Ks; Tue, 11 Jan 2022 14:58:35 +0000 Received: by outflank-mailman (input) for mailman id 255780; Tue, 11 Jan 2022 14:58:32 +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 1n7IbY-0002OZ-Dm for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:32 +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 ec131df5-72ee-11ec-81c1-a30af7de8005; Tue, 11 Jan 2022 15:58:23 +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 B94521F3C0; Tue, 11 Jan 2022 14:58:21 +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 904D013DDD; Tue, 11 Jan 2022 14:58:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MDb6IQ2b3WH9eQAAMHmgww (envelope-from ); Tue, 11 Jan 2022 14:58:21 +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: ec131df5-72ee-11ec-81c1-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641913101; 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=Y+cFyyKrZNtwGa8ajfw3LoYs6PEvCSgNiRQOqaGYZOo=; b=kE1dypH8RaMAizI9BnfmTJJoaByoAHqPkAxNRwEI1vXMOqIWuj+YZUzYdmhRKADy4ZaOiY 4R4H27w8skxfiJR6EAUJ2mu/y+XEPU6Hs25S+lyB0eP5r1vbjSrpzRa+3dSbbpr+psrRD3 kA1khR01z1NP+3Z4et6/Lz2djrkYWFQ= 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 v2 09/18] mini-os: eliminate kbdfront union member in struct file Date: Tue, 11 Jan 2022 15:58:08 +0100 Message-Id: <20220111145817.22170-10-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220111145817.22170-1-jgross@suse.com> References: <20220111145817.22170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641913141720100007 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 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 Mar 28 09:46:58 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=1641913139; cv=none; d=zohomail.com; s=zohoarc; b=eQF7z4Tt23X8gEcpbHXStl2vHMAVXNF8ZeMeYIQZ7MybiKEvqNHJAdccSnCm70zwyY+8HZIpzmpTQJwEybYInDFCvkM3tGzSk9bVXc10sh++/Ba8LN6evS593QzCF4VYZUtyGsFY9W6zBIiuzeJPp6PV+INAxxRT2vYsOIJtwQA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641913139; 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=TREXG7+5/igcPNPrnaoW0C+ol3WOPsTOJ1n+uetqVIM=; b=LGu/jhG22GvOhGQw/zDKvrZXmDfugSwMRaDR7fcoegPe182d70EkMwRbxx30jy4O8JA961p/j2DgyCw4kQ1ZBrmqPE8fnuBLN1vCMdJpkPCADfc3MNsUT6I8AHY3goG5CNsxqC4/Gto81gWjX897wbkmztsctp1f/n64qtuqIDs= 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 1641913139338524.0261285608557; Tue, 11 Jan 2022 06:58:59 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255768.438408 (Exim 4.92) (envelope-from ) id 1n7IbT-0002yQ-T4; Tue, 11 Jan 2022 14:58:27 +0000 Received: by outflank-mailman (output) from mailman id 255768.438408; Tue, 11 Jan 2022 14:58:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n7IbT-0002xY-LE; Tue, 11 Jan 2022 14:58:27 +0000 Received: by outflank-mailman (input) for mailman id 255768; Tue, 11 Jan 2022 14:58:26 +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 1n7IbS-0002OZ-Ci for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:26 +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 eb74dc4e-72ee-11ec-81c1-a30af7de8005; Tue, 11 Jan 2022 15:58:22 +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 E9B53212CA; Tue, 11 Jan 2022 14:58:21 +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 BFE8913DDD; Tue, 11 Jan 2022 14:58:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SM+DLQ2b3WH9eQAAMHmgww (envelope-from ); Tue, 11 Jan 2022 14:58:21 +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: eb74dc4e-72ee-11ec-81c1-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641913101; 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=TREXG7+5/igcPNPrnaoW0C+ol3WOPsTOJ1n+uetqVIM=; b=RMzEluR0R4fgFdGUYZlpRN9kcrLAm9FKaQhlsOwmr0NuaXYDlXIX2d9602zbkd5n3DldVS FWh6iw030rnPWCiK37hb+Kqi0mle91w9GKtHPMavCQJZCK0fT2kygkIPsxpMysR9NYHfHS vvB0GFH/b9YGFFmP7w1jRCSg3WT26KE= 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 v2 10/18] mini-os: eliminate netfront union member in struct file Date: Tue, 11 Jan 2022 15:58:09 +0100 Message-Id: <20220111145817.22170-11-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220111145817.22170-1-jgross@suse.com> References: <20220111145817.22170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641913141357100002 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 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 Mar 28 09:46:58 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=1641913139; cv=none; d=zohomail.com; s=zohoarc; b=b58VzchNK12EYA1lW8ah4Xvlf8Yo5kLDpF9dvCTza3TNJzVQRFGehdGi9CM+w7LX/ZqwRwYav01FUzG8PR0Lfb/0ECt1B5W1Iu9bqkJRID4Xen0NviEr1Ill7bbut6OLqOUBUGllaW6Y5x7/y7M6JLSkc3hLWujQjcEyTMdh9Zw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641913139; 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=Kc8vjPoaiZBPWJd7bC9/lWlsrU4qpi/hgSPUhZ8Wm48=; b=gUc4H/cqVpQGd8I4UvBGvE9SW7ivEKpXxo1H9Yjvvtxwwl/IYDb6zRRL6ubCpBvK94r2t1CF+xY18F6YWWKQlJ1IGnfLCGMFVF8L/Qyc2AjDm4WY9coh8wJQlRYHKa4pauQUK6mfyOFaI1DOjfXV1WzhL2SKYSoHaG0VMoMx9uE= 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 1641913139435122.1706816308639; Tue, 11 Jan 2022 06:58:59 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255772.438438 (Exim 4.92) (envelope-from ) id 1n7IbX-0003hB-0J; Tue, 11 Jan 2022 14:58:31 +0000 Received: by outflank-mailman (output) from mailman id 255772.438438; Tue, 11 Jan 2022 14:58:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n7IbW-0003gs-Qi; Tue, 11 Jan 2022 14:58:30 +0000 Received: by outflank-mailman (input) for mailman id 255772; Tue, 11 Jan 2022 14:58:28 +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 1n7IbU-0002OZ-Cx for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:28 +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 eb953028-72ee-11ec-81c1-a30af7de8005; Tue, 11 Jan 2022 15:58:22 +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 242F7212CB; Tue, 11 Jan 2022 14:58:22 +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 EF06413DDD; Tue, 11 Jan 2022 14:58:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gEULOQ2b3WH9eQAAMHmgww (envelope-from ); Tue, 11 Jan 2022 14:58:21 +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: eb953028-72ee-11ec-81c1-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641913102; 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=Kc8vjPoaiZBPWJd7bC9/lWlsrU4qpi/hgSPUhZ8Wm48=; b=LQxJ7OH+F7Zw7qdHdMyNJ2UZp9vmF7os301Zp+Ys8Ek/bMu0+EImR1SRe2hGXSSHeMo/QX xQUrY5LeQ8sRz0L1Ngdk93hAUn4RUUO17NZL8C36p2AKFBD8060iTmEiJtqjFrJOoZ/txp JkeH5ZgZyrLtps8OYkxDA+zWq5ReSdI= 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 v2 11/18] mini-os: move tpm respgot member of struct file to device specific data Date: Tue, 11 Jan 2022 15:58:10 +0100 Message-Id: <20220111145817.22170-12-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220111145817.22170-1-jgross@suse.com> References: <20220111145817.22170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641913141323100001 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 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 Mar 28 09:46:58 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=1641913799; cv=none; d=zohomail.com; s=zohoarc; b=W3Moo7git/7582dQ9Srcgear2woEFGy2dmOOrve1I04tp4/uZ0kivPIvRPl8VvXSyMGOs2hMfsNzYhZNdysrW2o4nf9q6U11lBncWmqq46Kg34CikG3PWv094b7cD3P+D24niiCjC2wn1mUd6gdPpCA09v/Gw9+hyA7n4iK14vE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641913799; 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=bYu3u434xIrAQdgw8rYV9Jpr+7UfDsZfUtYVg6rlj/g=; b=D67eSmlx9ULqm9rak8OR3cRv55M6lAso3+grN2RO6Zl56EPKYaYb9NyL49GLmgeFsDY/5dwS6FU2auHoZ1D3PTTmchYCmHGBUxiq8S36MrzpuLiF6zv7EQhcJJBmp5ZFR7jiwxdBT+maMa6DhM/EaThhHqKXIX0KWaCB5GTaE6w= 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 1641913799541623.1098548491277; Tue, 11 Jan 2022 07:09:59 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255839.438644 (Exim 4.92) (envelope-from ) id 1n7ImJ-00079T-AS; Tue, 11 Jan 2022 15:09:39 +0000 Received: by outflank-mailman (output) from mailman id 255839.438644; Tue, 11 Jan 2022 15:09:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n7ImJ-00079M-7I; Tue, 11 Jan 2022 15:09:39 +0000 Received: by outflank-mailman (input) for mailman id 255839; Tue, 11 Jan 2022 15:09: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 1n7Iba-0002OZ-Dx for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:34 +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 ec22a130-72ee-11ec-81c1-a30af7de8005; Tue, 11 Jan 2022 15:58:23 +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 525AD212CC; Tue, 11 Jan 2022 14:58:22 +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 2A2A313DDD; Tue, 11 Jan 2022 14:58:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kPEGCQ6b3WH9eQAAMHmgww (envelope-from ); Tue, 11 Jan 2022 14:58:22 +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: ec22a130-72ee-11ec-81c1-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641913102; 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=bYu3u434xIrAQdgw8rYV9Jpr+7UfDsZfUtYVg6rlj/g=; b=J3rgPmuEtBeQvoQJca4UnYfrUOjV1xo9h6RDBETYShjI5hzhYdMG/c270TX5v9LPhSMqDM YL2NDZPvYuGIGysONZxLf7UT5uhAl+sjK0zISGCk+LQDI/+7r4wlKjIoqori+NZw5uKQqi cX5wL7HX68hb4SvSod2FFS0SUVnIZF8= 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 v2 12/18] mini-os: eliminate tpmfront union member in struct file Date: Tue, 11 Jan 2022 15:58:11 +0100 Message-Id: <20220111145817.22170-13-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220111145817.22170-1-jgross@suse.com> References: <20220111145817.22170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641913801122100005 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 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 Mar 28 09:46:58 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=1641913769; cv=none; d=zohomail.com; s=zohoarc; b=VowMXWCKsPiY0HSR+2dLDGd9z0H/JRWMobbIYE0tVRwBB1lvEqKCjtGgEAXZl4eIAhfdplKxlmAkTebNMLkAABnaIxcfmGtbPencyS920un/DDf+DeNuVWFFRU5rvNwmzA4ZZcjJvHfmYhfdUCKEtRUemWwdVDpWVIENYEn9yqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641913769; 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=KvYWbjQdT5GoXtl6mz9SWgGWXv1kuFR3GbeV+mNScb0=; b=HTyCB2Xi4dh1lGqBbCGQJEf5tp5WratBIFfHqOL0ZL932cK5Gui/e40dJhMPucmrlwFdTDYQoYD+xBW+be95Iih4GUHfE7KX0bf1dQBcOpbNnCh2AOxZH/fLAzxjYVV02ubVsIzW/czC5BMoQDcx1/qACiDLSNFNSTrYQJDiWE8= 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 1641913769387681.6745702344637; Tue, 11 Jan 2022 07:09:29 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255835.438633 (Exim 4.92) (envelope-from ) id 1n7Ily-0006Wa-2E; Tue, 11 Jan 2022 15:09:18 +0000 Received: by outflank-mailman (output) from mailman id 255835.438633; Tue, 11 Jan 2022 15:09:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n7Ilx-0006WR-Uy; Tue, 11 Jan 2022 15:09:17 +0000 Received: by outflank-mailman (input) for mailman id 255835; Tue, 11 Jan 2022 15:09:16 +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 1n7Ibe-0002Oa-Dw for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:38 +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 ec28f894-72ee-11ec-9ce5-af14b9085ebd; Tue, 11 Jan 2022 15:58:23 +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 7F4EF212FE; Tue, 11 Jan 2022 14:58:22 +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 57EB513DDD; Tue, 11 Jan 2022 14:58:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8ChLFA6b3WH9eQAAMHmgww (envelope-from ); Tue, 11 Jan 2022 14:58:22 +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: ec28f894-72ee-11ec-9ce5-af14b9085ebd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641913102; 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=KvYWbjQdT5GoXtl6mz9SWgGWXv1kuFR3GbeV+mNScb0=; b=G5OptETgBTozBz2qWhqOixO5JISC2ALgWTGURLKUH6TNPZ/TK9D7pF1bqPq4UUBseMmSSu gsXy9+5mgYmu1NDAkInUF6fBIyqoUcAwHtU7cKZQoEQ4KJFY9bqhgpMmi1x40j0szk1Fm7 0q7+NhNaWmWlQIgpZe7ICP/FqoBE5kI= 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 v2 13/18] mini-os: eliminate tpmtis union member in struct file Date: Tue, 11 Jan 2022 15:58:12 +0100 Message-Id: <20220111145817.22170-14-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220111145817.22170-1-jgross@suse.com> References: <20220111145817.22170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641913771399100001 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 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 Mar 28 09:46:58 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=1641913679; cv=none; d=zohomail.com; s=zohoarc; b=LlSnOpHdkOm0KTgolNkPBlCi5HC0Kf+rgbdXqV4RsRe+uLLY0dhRPZl4NA0A6MqSlxOCF3cq3EngmjP0JcZmP6AjdBpdXkp9xYgEyXKHUYIyrOCklxGGficItwJJtmJBrgkESwiNrqecFQndG+ej59T8d2s1DDxjS5qeAN0NAPU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641913679; 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=n40BkLdnJT4X941oqOUKglJdlkxVA0w5hYfz6J0OaY8=; b=XA8I00a0viUoAPZH3wxy7D+zb3a7Z60EOQV8zX42ARsgbE0YHjy7vRupsnc8ZFfduUIqmd4+7ijQeIKFZADuTbVSJ3xdEiEAq+KLzl1Tz8TSdoUWvX/JZbvufg3Bh51MgA05+EqJmiBva34oKaB1I58lr+8qDpdy8yDjaztIX4M= 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 164191367998570.03857655278352; Tue, 11 Jan 2022 07:07:59 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255816.438588 (Exim 4.92) (envelope-from ) id 1n7IkO-0004KW-T5; Tue, 11 Jan 2022 15:07:40 +0000 Received: by outflank-mailman (output) from mailman id 255816.438588; Tue, 11 Jan 2022 15:07:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n7IkO-0004KP-Pi; Tue, 11 Jan 2022 15:07:40 +0000 Received: by outflank-mailman (input) for mailman id 255816; Tue, 11 Jan 2022 15:07:39 +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 1n7Ibe-0002OZ-F3 for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:38 +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 ec38fac3-72ee-11ec-81c1-a30af7de8005; Tue, 11 Jan 2022 15:58:23 +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 ADCAD21637; Tue, 11 Jan 2022 14:58:22 +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 8537013DDD; Tue, 11 Jan 2022 14:58:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 4OZLHw6b3WH9eQAAMHmgww (envelope-from ); Tue, 11 Jan 2022 14:58:22 +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: ec38fac3-72ee-11ec-81c1-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641913102; 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=n40BkLdnJT4X941oqOUKglJdlkxVA0w5hYfz6J0OaY8=; b=ZjfrY70i0Pbr4czUKwgXjbY1iNrCDw3Vx6pB0YdsaGN7XkJEQRb6KDvlppTR00fiMkgicg b96gcYYWqzLUeAJWntujpY/xohdNP0T70OPGYx0tVAzuIvA29EQPP9efelRGjtJfBy8EA8 R3CGUCNryEYA3V2yaKv5C6rJtjM1OBk= 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 v2 14/18] mini-os: eliminate xenbus union member in struct file Date: Tue, 11 Jan 2022 15:58:13 +0100 Message-Id: <20220111145817.22170-15-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220111145817.22170-1-jgross@suse.com> References: <20220111145817.22170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641913682469100001 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 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 Mar 28 09:46:58 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=1641913798; cv=none; d=zohomail.com; s=zohoarc; b=LX4YzARCBmXGR3zWBLU/Z+NLWuTCVzDL259ZnjDmlNqTE3ueitvRsryLSMj5G7sLkaP2810pP6bo5aHKvcEk1BYLER17yYGKx5l6RIcKtWdylxhHID9U4vi3IGGUy48MTv2ZGkmBOHReUBUEFGifa6O7T4SBDt1pwTWEBoe2PVg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641913798; 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=C9AyKNzGKENy2BPxgLKGB+hFKK51Mm2oD341mOYK6aA=; b=QqVkWPnttAuW4ttdu0pmIHdDOdql+eiUXMhioDfNzmYW3hY7ujqqIPXH8Wpls0i+ooWeFku/omKcvCwdI22/sn0kpTjqMZsT3CPng1ei4KuO8lqvn84XrrJYnfZo1G4OeOVNrUSDAN6aw03AsMDmyEMPK07umUG4OTy9Pr/FLVM= 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 1641913798406439.88799004783505; Tue, 11 Jan 2022 07:09:58 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255844.438662 (Exim 4.92) (envelope-from ) id 1n7ImO-0007YN-P9; Tue, 11 Jan 2022 15:09:44 +0000 Received: by outflank-mailman (output) from mailman id 255844.438662; Tue, 11 Jan 2022 15:09:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n7ImO-0007Xi-I7; Tue, 11 Jan 2022 15:09:44 +0000 Received: by outflank-mailman (input) for mailman id 255844; Tue, 11 Jan 2022 15:09:44 +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 1n7Ibg-0002Oa-ED for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:40 +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 ec3e09a2-72ee-11ec-9ce5-af14b9085ebd; Tue, 11 Jan 2022 15:58:23 +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 DAF8921639; Tue, 11 Jan 2022 14:58:22 +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 B2F4A13DDD; Tue, 11 Jan 2022 14:58:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SEeCKg6b3WH9eQAAMHmgww (envelope-from ); Tue, 11 Jan 2022 14:58:22 +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: ec3e09a2-72ee-11ec-9ce5-af14b9085ebd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641913102; 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=C9AyKNzGKENy2BPxgLKGB+hFKK51Mm2oD341mOYK6aA=; b=R0GKkNi+dhG4W5lbRM9+2Frk+rVnQIdIdPOS8v8+F5cg1HTIkgQ6Y2/3UjnpFCRPAvzP5m B9FDuzQpDzsnvybo9xP0Yqg7Jru3vd1W3D73Ff6vapQ7YP1JmJxUeMmNHTjZs94re/0DP5 8Q+Wk/oJuwX3UQnpVGwHfiG/VouWXf8= 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 v2 15/18] mini-os: introduce get_file_from_fd() Date: Tue, 11 Jan 2022 15:58:14 +0100 Message-Id: <20220111145817.22170-16-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220111145817.22170-1-jgross@suse.com> References: <20220111145817.22170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641913800717100001 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 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 From nobody Thu Mar 28 09:46:58 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=1641913816; cv=none; d=zohomail.com; s=zohoarc; b=m6vjJE5Bbj13Uak+ZYBUHTB2+B4gcS3nlLwwHTbR9sExsQrG7Ejoi+koDu+WhixSy+ZuUV+SuQqTMLQYJPbkTouf2LgTGsuOBIBrDcJKMt0LlM83zf5nXgviurSXo1kX4gFrxBN5umxa0HmLFLwy9rgCURc9nCTKwAhTEwsRMZ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641913816; 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=knuLUyCcfoEXY1jmZHvU06lOttBFfXuiA3Ntm0yi0WI=; b=ExDxOqklzZWyQXa6zVzJv+wZnV8ywYmfa1RAaNMIoZSh0FfQ57TkwRCuQf3Six3QqcQujWFVPcfrVr1lAdlWDLKQmanuVisBNFur9N9unSe+g8RSjSmTtK+hQwwLyHOv7jzILh2JGtNzJpVdrtVe1Xaqt22b4UeENl6xpUgyNHA= 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 1641913816076691.7437113719545; Tue, 11 Jan 2022 07:10:16 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255851.438689 (Exim 4.92) (envelope-from ) id 1n7Imi-0000sP-Ap; Tue, 11 Jan 2022 15:10:04 +0000 Received: by outflank-mailman (output) from mailman id 255851.438689; Tue, 11 Jan 2022 15:10: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 1n7Imi-0000rj-6q; Tue, 11 Jan 2022 15:10:04 +0000 Received: by outflank-mailman (input) for mailman id 255851; Tue, 11 Jan 2022 15:10: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 1n7Ibb-0002OZ-EE for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:35 +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 ec1fdd83-72ee-11ec-81c1-a30af7de8005; Tue, 11 Jan 2022 15:58:23 +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 140D51F3B1; Tue, 11 Jan 2022 14:58:23 +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 E0D4013DDD; Tue, 11 Jan 2022 14:58:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sJu6NQ6b3WH9eQAAMHmgww (envelope-from ); Tue, 11 Jan 2022 14:58:22 +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: ec1fdd83-72ee-11ec-81c1-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641913103; 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=knuLUyCcfoEXY1jmZHvU06lOttBFfXuiA3Ntm0yi0WI=; b=EFpQEMzDRCsLhCQBXwK2k2H3BhcEPZ6mVmlXCvtDA/t5hqCYWRSifDDghM0bRqeB/Qviyh 226/HA9B/EhvS77A5nxG4pPc5UV+IDGh3+e2NK89RF4Bd1b3r8ng47I4kh+vQxhzdzkNbt nPZY+aEIcM6SVKcxKbIOD8iDXcpP6Ks= 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 v2 16/18] mini-os: reset file type in close() in one place only Date: Tue, 11 Jan 2022 15:58:15 +0100 Message-Id: <20220111145817.22170-17-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220111145817.22170-1-jgross@suse.com> References: <20220111145817.22170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641913817417100001 Content-Type: text/plain; charset="utf-8" Today the file type in struct file is set to FTYPE_NONE for each file type individually. Do that at the end of close() handling for all types. While at it wipe the complete struct file, too, in order to avoid old data creeping into a new allocated struct file. Signed-off-by: Juergen Gross Reviewed-by: Samuel Thibault --- V2: - new patch --- lib/sys.c | 53 ++++++++++++++++++++++++----------------------------- lib/xs.c | 1 - 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/lib/sys.c b/lib/sys.c index 0e6fe5d..323a7cd 100644 --- a/lib/sys.c +++ b/lib/sys.c @@ -424,87 +424,82 @@ int fsync(int fd) { =20 int close(int fd) { + int res =3D 0; + printk("close(%d)\n", fd); switch (files[fd].type) { default: - files[fd].type =3D FTYPE_NONE; - return 0; + break; #ifdef CONFIG_XENBUS case FTYPE_XENBUS: xs_daemon_close((void*)(intptr_t) fd); - return 0; + break; #endif #ifdef HAVE_LWIP - case FTYPE_SOCKET: { - int res =3D lwip_close(files[fd].fd); - files[fd].type =3D FTYPE_NONE; - return res; - } + case FTYPE_SOCKET: + res =3D lwip_close(files[fd].fd); + break; #endif #ifdef CONFIG_LIBXENCTRL case FTYPE_XC: minios_interface_close_fd(fd); - return 0; + break; #endif #ifdef CONFIG_LIBXENEVTCHN case FTYPE_EVTCHN: minios_evtchn_close_fd(fd); - return 0; + break; #endif #ifdef CONFIG_LIBXENGNTTAB case FTYPE_GNTMAP: minios_gnttab_close_fd(fd); - return 0; + break; #endif #ifdef CONFIG_NETFRONT case FTYPE_TAP: shutdown_netfront(files[fd].dev); - files[fd].type =3D FTYPE_NONE; - return 0; + break; #endif #ifdef CONFIG_BLKFRONT case FTYPE_BLK: shutdown_blkfront(files[fd].dev); - files[fd].type =3D FTYPE_NONE; - return 0; + break; #endif #ifdef CONFIG_TPMFRONT case FTYPE_TPMFRONT: shutdown_tpmfront(files[fd].dev); - files[fd].type =3D FTYPE_NONE; - return 0; + break; #endif #ifdef CONFIG_TPM_TIS case FTYPE_TPM_TIS: shutdown_tpm_tis(files[fd].dev); - files[fd].type =3D FTYPE_NONE; - return 0; + break; #endif #ifdef CONFIG_KBDFRONT case FTYPE_KBD: shutdown_kbdfront(files[fd].dev); - files[fd].type =3D FTYPE_NONE; - return 0; + break; #endif #ifdef CONFIG_FBFRONT case FTYPE_FB: shutdown_fbfront(files[fd].dev); - files[fd].type =3D FTYPE_NONE; - return 0; + break; #endif #ifdef CONFIG_CONSFRONT case FTYPE_SAVEFILE: case FTYPE_CONSOLE: fini_consfront(files[fd].dev); - files[fd].type =3D FTYPE_NONE; - return 0; + break; #endif case FTYPE_NONE: - break; + printk("close(%d): Bad descriptor\n", fd); + errno =3D EBADF; + return -1; } - printk("close(%d): Bad descriptor\n", fd); - errno =3D EBADF; - return -1; + + memset(files + fd, 0, sizeof(struct file)); + files[fd].type =3D FTYPE_NONE; + return res; } =20 static void init_stat(struct stat *buf) diff --git a/lib/xs.c b/lib/xs.c index 0459f52..4af0f96 100644 --- a/lib/xs.c +++ b/lib/xs.c @@ -35,7 +35,6 @@ void xs_daemon_close(struct xs_handle *h) next =3D event->next; free(event); } - files[fd].type =3D FTYPE_NONE; } =20 int xs_fileno(struct xs_handle *h) --=20 2.26.2 From nobody Thu Mar 28 09:46:58 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=1641913723; cv=none; d=zohomail.com; s=zohoarc; b=ZIc/b4S6qvT++IXz5FosCWKt+r+gAfXUEIxo7bCeSV+Bzh/i0i5l3sQILVFFGLNatQxtMGPDAP4t5eZl7V98q14aElwM/oVelJKTuoK8rbu6x+judz34ARLa1DcutOVfph1xclxtuPVYSFLxnB+DQYEH+Goh5hoOgmUVkm/eHwc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641913723; 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=LhH/Bo3lirfkf7NoVUI5lwaB8z0a64DTHY6OLddxQ6Q=; b=YkLZGxryUZuJuYIha97gj/Gcxnpc9fVwDcA5l/X+fe0IBKnEr3hx8LLW3OsSvTeIn0k+7DnV2Y3/6RkuArszqsZzOy1E/QrsGw556+jYsMMQY3O5HA3QUJQA52T/Xtl8EJtB+SQz1v28RIAnglHqXA8HnQlCTFPP+wogi3xyvSM= 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 1641913723016837.8552835932808; Tue, 11 Jan 2022 07:08:43 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255823.438603 (Exim 4.92) (envelope-from ) id 1n7Il8-0005EY-7Q; Tue, 11 Jan 2022 15:08:26 +0000 Received: by outflank-mailman (output) from mailman id 255823.438603; Tue, 11 Jan 2022 15:08:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n7Il8-0005ER-4B; Tue, 11 Jan 2022 15:08:26 +0000 Received: by outflank-mailman (input) for mailman id 255823; Tue, 11 Jan 2022 15:08:25 +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 1n7Ibi-0002Oa-EL for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:42 +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 ec45faef-72ee-11ec-9ce5-af14b9085ebd; Tue, 11 Jan 2022 15:58:23 +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 476361F3BB; Tue, 11 Jan 2022 14:58:23 +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 1B56813DDD; Tue, 11 Jan 2022 14:58:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2Jl+BQ+b3WH9eQAAMHmgww (envelope-from ); Tue, 11 Jan 2022 14:58:23 +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: ec45faef-72ee-11ec-9ce5-af14b9085ebd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641913103; 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=LhH/Bo3lirfkf7NoVUI5lwaB8z0a64DTHY6OLddxQ6Q=; b=N0yIni7CUgPltcFS9sVSL589r0Kj+q5S/ADpIDzeweucEGAEh95WRb6hVaOCFkGNvGKyMo GVSiEJ0yZ6jqAnsDEtRT39cSKfH7pD5P21357Md51nDjxBhuWFvRxsmHsPGLSgxXjyOg5T GJyQlwHB1lVrXjMeIUz3gngOpJs3REc= 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 v2 17/18] mini-os: use function vectors instead of switch for file operations Date: Tue, 11 Jan 2022 15:58:16 +0100 Message-Id: <20220111145817.22170-18-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220111145817.22170-1-jgross@suse.com> References: <20220111145817.22170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641913725161100001 Content-Type: text/plain; charset="utf-8" Introduce file type specific function vectors for all the needed file operations which are file type specific in order to prepare replacing the large switch statements in each generic file function. Add a function to allocate a new file type dynamically in order to prepare removing direct dependencies to external components in the future. For this reason switch the file type from an enum to an unsigned int. Prepare removal of some statically defines file types by putting them at the end of the defined list. Change the debug output for the file type from a single character to a string in order to support a future removal of the file_types[] array. Signed-off-by: Juergen Gross --- V2: - new patch --- include/lib.h | 65 +++++++++++----- lib/sys.c | 208 +++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 217 insertions(+), 56 deletions(-) diff --git a/include/lib.h b/include/lib.h index 7a0546b..b40e213 100644 --- a/include/lib.h +++ b/include/lib.h @@ -66,6 +66,7 @@ =20 #ifdef HAVE_LIBC #include +#include #include #include #else @@ -154,25 +155,51 @@ do { = \ void sanity_check(void); =20 #ifdef HAVE_LIBC -enum fd_type { - FTYPE_NONE =3D 0, - FTYPE_CONSOLE, - FTYPE_FILE, - FTYPE_XENBUS, - FTYPE_XC, - FTYPE_EVTCHN, - FTYPE_GNTMAP, - FTYPE_SOCKET, - FTYPE_TAP, - FTYPE_BLK, - FTYPE_KBD, - FTYPE_FB, - FTYPE_MEM, - FTYPE_SAVEFILE, - FTYPE_TPMFRONT, - FTYPE_TPM_TIS, +#define FTYPE_NONE 0 +#define FTYPE_CONSOLE 1 +#define FTYPE_FILE 2 +#define FTYPE_SOCKET 3 +#define FTYPE_MEM 4 +#define FTYPE_SAVEFILE 5 +#define FTYPE_FB 6 +#define FTYPE_KBD 7 +#define FTYPE_TAP 8 +#define FTYPE_BLK 9 +#define FTYPE_TPMFRONT 10 +#define FTYPE_TPM_TIS 11 +#define FTYPE_XENBUS 12 +#define FTYPE_GNTMAP 13 +#define FTYPE_EVTCHN 14 +#define FTYPE_XC 15 +#define FTYPE_N 16 +#define FTYPE_SPARE 16 + +typedef int file_read_func(int fd, void *buf, size_t nbytes); +typedef int file_write_func(int fd, const void *buf, size_t nbytes); +typedef off_t file_lseek_func(int fd, off_t offset, int whence); +typedef int file_close_func(int fd); +typedef int file_fstat_func(int fd, struct stat *buf); +typedef int file_fcntl_func(int fd, int cmd, va_list args); +typedef bool file_select_func(int fd); + +struct file_ops { + const char *name; + file_read_func *read; + file_write_func *write; + file_lseek_func *lseek; + file_close_func *close; + file_fstat_func *fstat; + file_fcntl_func *fcntl; + file_select_func *select_rd; + file_select_func *select_wr; }; =20 +unsigned int alloc_file_type(struct file_ops *ops); + +off_t lseek_default(int fd, off_t offset, int whence); +bool select_yes(int fd); +bool select_read_flag(int fd); + LIST_HEAD(evtchn_port_list, evtchn_port_info); =20 struct evtchn_port_info { @@ -183,7 +210,7 @@ struct evtchn_port_info { }; =20 struct file { - enum fd_type type; + unsigned int type; bool read; /* maybe available for read */ off_t offset; union { @@ -199,7 +226,7 @@ struct file { extern struct file files[]; =20 struct file *get_file_from_fd(int fd); -int alloc_fd(enum fd_type type); +int alloc_fd(unsigned int type); void close_all_files(void); extern struct thread *main_thread; void sparse(unsigned long data, size_t size); diff --git a/lib/sys.c b/lib/sys.c index 323a7cd..c327247 100644 --- a/lib/sys.c +++ b/lib/sys.c @@ -98,6 +98,39 @@ struct file files[NOFILE] =3D { { .type =3D FTYPE_CONSOLE }, /* stderr */ }; =20 +static struct file_ops file_ops_none =3D { + .name =3D "none", +}; + +static struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] =3D { + [FTYPE_NONE] =3D &file_ops_none, +}; + +unsigned int alloc_file_type(struct file_ops *ops) +{ + unsigned int i; + + pthread_mutex_lock(&fd_lock); + + for ( i =3D FTYPE_N; i < ARRAY_SIZE(file_ops) && file_ops[i]; i++ ); + BUG_ON(i =3D=3D ARRAY_SIZE(file_ops)); + file_ops[i] =3D ops; + + pthread_mutex_unlock(&fd_lock); + + printk("New file type \"%s\"(%u) allocated\n", ops->name, i); + + return i; +} + +static struct file_ops *get_file_ops(unsigned int type) +{ + if ( type >=3D ARRAY_SIZE(file_ops) || !file_ops[type] ) + return &file_ops_none; + + return file_ops[type]; +} + struct file *get_file_from_fd(int fd) { if ( fd < 0 || fd >=3D NOFILE ) @@ -108,7 +141,7 @@ struct file *get_file_from_fd(int fd) =20 DECLARE_WAIT_QUEUE_HEAD(event_queue); =20 -int alloc_fd(enum fd_type type) +int alloc_fd(unsigned int type) { int i; pthread_mutex_lock(&fd_lock); @@ -249,6 +282,11 @@ int isatty(int fd) =20 int read(int fd, void *buf, size_t nbytes) { + struct file_ops *ops =3D get_file_ops(files[fd].type); + + if ( ops->read ) + return ops->read(fd, buf, nbytes); + switch (files[fd].type) { case FTYPE_SAVEFILE: case FTYPE_CONSOLE: { @@ -328,6 +366,11 @@ int read(int fd, void *buf, size_t nbytes) =20 int write(int fd, const void *buf, size_t nbytes) { + struct file_ops *ops =3D get_file_ops(files[fd].type); + + if ( ops->write ) + return ops->write(fd, buf, nbytes); + switch (files[fd].type) { case FTYPE_SAVEFILE: { int ret =3D 0, tot =3D nbytes; @@ -370,8 +413,45 @@ int write(int fd, const void *buf, size_t nbytes) return -1; } =20 +off_t lseek_default(int fd, off_t offset, int whence) +{ + switch ( whence ) + { + case SEEK_SET: + files[fd].offset =3D offset; + break; + + case SEEK_CUR: + files[fd].offset +=3D offset; + break; + + case SEEK_END: + { + struct stat st; + int ret; + + ret =3D fstat(fd, &st); + if ( ret ) + return -1; + files[fd].offset =3D st.st_size + offset; + break; + } + + default: + errno =3D EINVAL; + return -1; + } + + return files[fd].offset; +} + off_t lseek(int fd, off_t offset, int whence) { + struct file_ops *ops =3D get_file_ops(files[fd].type); + + if ( ops->lseek ) + return ops->lseek(fd, offset, whence); + switch(files[fd].type) { #ifdef CONFIG_BLKFRONT case FTYPE_BLK: @@ -393,28 +473,7 @@ off_t lseek(int fd, off_t offset, int whence) return (off_t) -1; } =20 - switch (whence) { - case SEEK_SET: - files[fd].offset =3D offset; - break; - case SEEK_CUR: - files[fd].offset +=3D offset; - break; - case SEEK_END: - { - struct stat st; - int ret; - ret =3D fstat(fd, &st); - if (ret) - return -1; - files[fd].offset =3D st.st_size + offset; - break; - } - default: - errno =3D EINVAL; - return -1; - } - return files[fd].offset; + return lseek_default(fd, offset, whence); } =20 int fsync(int fd) { @@ -425,8 +484,15 @@ int fsync(int fd) { int close(int fd) { int res =3D 0; + struct file_ops *ops =3D get_file_ops(files[fd].type); =20 printk("close(%d)\n", fd); + if ( ops->close ) + { + res =3D ops->close(fd); + goto out; + } + switch (files[fd].type) { default: break; @@ -497,6 +563,7 @@ int close(int fd) return -1; } =20 + out: memset(files + fd, 0, sizeof(struct file)); files[fd].type =3D FTYPE_NONE; return res; @@ -521,7 +588,13 @@ int stat(const char *path, struct stat *buf) =20 int fstat(int fd, struct stat *buf) { + struct file_ops *ops =3D get_file_ops(files[fd].type); + init_stat(buf); + + if ( ops->fstat ) + return ops->fstat(fd, buf); + switch (files[fd].type) { case FTYPE_SAVEFILE: case FTYPE_CONSOLE: @@ -587,6 +660,18 @@ int fcntl(int fd, int cmd, ...) { long arg; va_list ap; + int res; + struct file_ops *ops =3D get_file_ops(files[fd].type); + + if ( ops->fcntl ) + { + va_start(ap, cmd); + res =3D ops->fcntl(fd, cmd, ap); + va_end(ap); + + return res; + } + va_start(ap, cmd); arg =3D va_arg(ap, long); va_end(ap); @@ -640,18 +725,29 @@ int closedir(DIR *dir) /* We assume that only the main thread calls select(). */ =20 #if defined(LIBC_DEBUG) || defined(LIBC_VERBOSE) -static const char file_types[] =3D { - [FTYPE_NONE] =3D 'N', - [FTYPE_CONSOLE] =3D 'C', - [FTYPE_XENBUS] =3D 'S', - [FTYPE_XC] =3D 'X', - [FTYPE_EVTCHN] =3D 'E', - [FTYPE_SOCKET] =3D 's', - [FTYPE_TAP] =3D 'T', - [FTYPE_BLK] =3D 'B', - [FTYPE_KBD] =3D 'K', - [FTYPE_FB] =3D 'G', +static const char *file_types[] =3D { + [FTYPE_NONE] =3D "none", + [FTYPE_CONSOLE] =3D "console", + [FTYPE_XENBUS] =3D "xenbus", + [FTYPE_XC] =3D "ctrl", + [FTYPE_EVTCHN] =3D "evtchn", + [FTYPE_SOCKET] =3D "socket", + [FTYPE_TAP] =3D "net", + [FTYPE_BLK] =3D "blk", + [FTYPE_KBD] =3D "kbd", + [FTYPE_FB] =3D "fb", }; + +static char *get_type_name(unsigned int type) +{ + if ( type < ARRAY_SIZE(file_ops) && file_ops[type] ) + return file_ops[type]->name; + + if ( type < ARRAY_SIZE(file_types) && file_types[type] ) + return file_types[type]; + + return "none"; +} #endif #ifdef LIBC_DEBUG static void dump_set(int nfds, fd_set *readfds, fd_set *writefds, fd_set *= exceptfds, struct timeval *timeout) @@ -663,7 +759,7 @@ static void dump_set(int nfds, fd_set *readfds, fd_set = *writefds, fd_set *except if (FD_ISSET(i, set)) { \ if (comma) \ printk(", "); \ - printk("%d(%c)", i, file_types[files[i].type]); \ + printk("%d(%s)", i, get_type_name(files[i].type)); \ comma =3D 1; \ } \ } \ @@ -697,7 +793,7 @@ static void dump_pollfds(struct pollfd *pfd, int nfds, = int timeout) fd =3D pfd[i].fd; if (comma) printk(", "); - printk("%d(%c)/%02x", fd, file_types[files[fd].type], + printk("%d(%s)/%02x", fd, get_type_name(files[fd].type), pfd[i].events); comma =3D 1; } @@ -709,6 +805,18 @@ static void dump_pollfds(struct pollfd *pfd, int nfds,= int timeout) #define dump_pollfds(pfds, nfds, timeout) #endif =20 +bool select_yes(int fd) +{ + return true; +} + +bool select_read_flag(int fd) +{ + struct file *file =3D get_file_from_fd(fd); + + return file->read; +} + /* Just poll without blocking */ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set= *exceptfds) { @@ -762,9 +870,35 @@ static int select_poll(int nfds, fd_set *readfds, fd_s= et *writefds, fd_set *exce for (i =3D 0; i < nfds; i++) { switch(files[i].type) { default: + { + struct file_ops *ops =3D file_ops[files[i].type]; + + if ( ops ) + { + if ( FD_ISSET(i, readfds) ) + { + if ( ops->select_rd && ops->select_rd(i) ) + n++; + else + FD_CLR(i, readfds); + } + if ( FD_ISSET(i, writefds) ) + { + if ( ops->select_wr && ops->select_wr(i) ) + n++; + else + FD_CLR(i, writefds); + } + FD_CLR(i, exceptfds); + + break; + } + if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i, exce= ptfds)) printk("bogus fd %d in select\n", i); /* Fallthrough. */ + } + case FTYPE_CONSOLE: if (FD_ISSET(i, readfds)) { if (xencons_ring_avail(files[i].dev)) @@ -842,7 +976,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_se= t *writefds, fd_set *exce printk("%d(%d): ", nb, sock_n); for (i =3D 0; i < nfds; i++) { if (nbread[i] || nbwrite[i] || nbexcept[i]) - printk(" %d(%c):", i, file_types[files[i].type]); + printk(" %d(%c):", i, get_type_name(files[i].type)); if (nbread[i]) printk(" %dR", nbread[i]); if (nbwrite[i]) --=20 2.26.2 From nobody Thu Mar 28 09:46:58 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=1641913678; cv=none; d=zohomail.com; s=zohoarc; b=gOpIkLN2+mBRAR7q774EzJsQCIBVS/OPwXJFoKQksGqSsuer9zw3CsoJBDWmCnULimkI+8pnyag3py7JG1PifB4ys4aQHo0CKkkoCp+17cJcMbVyF7DQjehPd8IGfX5cbxSE1Cps03i/5pVxi/pKw3YC2lUJiJ8nSCcUMntjo3c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641913678; 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=3MRu1fvGvRxSYETAwaGXHjdx6AuZiPRv8J9xLv9qXpA=; b=ZW9eSyXRx4fB/ndlC2aUPpYf0F3KTNldf5FpHDiXvdOOvv/Ra8G9TS8u8im5WAIs4nK00fm/TFNPcYKKmSvEj3I3VLXsc7PRRZOaD1x7gawVIm96M+SE7wQ9akHowM061KLUGX9ewYMwUqIF5oKxWkcU8UcUKM76QjrvLP/iF38= 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 1641913678386738.5080964907055; Tue, 11 Jan 2022 07:07:58 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255815.438577 (Exim 4.92) (envelope-from ) id 1n7IkN-00043a-L4; Tue, 11 Jan 2022 15:07:39 +0000 Received: by outflank-mailman (output) from mailman id 255815.438577; Tue, 11 Jan 2022 15:07:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n7IkN-00043T-Hd; Tue, 11 Jan 2022 15:07:39 +0000 Received: by outflank-mailman (input) for mailman id 255815; Tue, 11 Jan 2022 15:07:38 +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 1n7Ibg-0002OZ-FQ for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 14:58:40 +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 ec5ddb25-72ee-11ec-81c1-a30af7de8005; Tue, 11 Jan 2022 15:58:23 +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 75CCC212C3; Tue, 11 Jan 2022 14:58:23 +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 4E6D313DDD; Tue, 11 Jan 2022 14:58:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cBnnEQ+b3WH9eQAAMHmgww (envelope-from ); Tue, 11 Jan 2022 14:58:23 +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: ec5ddb25-72ee-11ec-81c1-a30af7de8005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641913103; 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=3MRu1fvGvRxSYETAwaGXHjdx6AuZiPRv8J9xLv9qXpA=; b=cE07+p9X7+a1mj4Yq/WttMObovohhvxLc1iNnnT+9yGsXpv/JCEv5uPOVrQkkzW+GVDEFD hHF+ZUGCyNqcCpqZuTDGXeowTB3PdeAJ6YPJvhD5e/ldwx7SRGZ5efDmP0zugqxIC+1crm 4ANsHXOr9LvGgFLPD49G9lNF3CLgF48= 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 v2 18/18] mini-os: remove file type FTYPE_XC Date: Tue, 11 Jan 2022 15:58:17 +0100 Message-Id: <20220111145817.22170-19-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220111145817.22170-1-jgross@suse.com> References: <20220111145817.22170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1641913679842100001 Content-Type: text/plain; charset="utf-8" The only reason for the file type FTYPE_XC has been gone long time ago: it was needed for xc_map_foreign_bulk(), which has been switched to use libxenforeignmemory and doesn't need this special file any more. So remove everything related to FTYPE_XC. Signed-off-by: Juergen Gross --- V2: - new patch --- Config.mk | 1 - arch/x86/testbuild/all-no | 1 - arch/x86/testbuild/all-yes | 1 - arch/x86/testbuild/newxen-yes | 1 - include/lib.h | 3 +-- lib/sys.c | 13 ------------- 6 files changed, 1 insertion(+), 19 deletions(-) diff --git a/Config.mk b/Config.mk index 5e66089..1e08388 100644 --- a/Config.mk +++ b/Config.mk @@ -197,7 +197,6 @@ CONFIG-n +=3D CONFIG_PARAVIRT endif # Support legacy CONFIG_XC value CONFIG_XC ?=3D $(libc) -CONFIG-$(CONFIG_XC) +=3D CONFIG_LIBXENCTRL CONFIG-$(CONFIG_XC) +=3D CONFIG_LIBXENEVTCHN CONFIG-$(CONFIG_XC) +=3D CONFIG_LIBXENGNTTAB =20 diff --git a/arch/x86/testbuild/all-no b/arch/x86/testbuild/all-no index 7972ecd..d6fc260 100644 --- a/arch/x86/testbuild/all-no +++ b/arch/x86/testbuild/all-no @@ -13,7 +13,6 @@ CONFIG_FBFRONT =3D n CONFIG_KBDFRONT =3D n CONFIG_CONSFRONT =3D n CONFIG_XENBUS =3D n -CONFIG_LIBXENCTRL =3D n CONFIG_LIBXENEVTCHN =3D n CONFIG_LIBXENGNTTAB =3D n CONFIG_LWIP =3D n diff --git a/arch/x86/testbuild/all-yes b/arch/x86/testbuild/all-yes index bc8eea5..98bbfeb 100644 --- a/arch/x86/testbuild/all-yes +++ b/arch/x86/testbuild/all-yes @@ -16,7 +16,6 @@ CONFIG_XENBUS =3D y CONFIG_BALLOON =3D y CONFIG_USE_XEN_CONSOLE =3D y # The following are special: they need support from outside -CONFIG_LIBXENCTRL =3D n CONFIG_LIBXENEVTCHN =3D n CONFIG_LIBXENGNTTAB =3D n CONFIG_LWIP =3D n diff --git a/arch/x86/testbuild/newxen-yes b/arch/x86/testbuild/newxen-yes index f72123b..0603200 100644 --- a/arch/x86/testbuild/newxen-yes +++ b/arch/x86/testbuild/newxen-yes @@ -17,7 +17,6 @@ CONFIG_BALLOON =3D y CONFIG_USE_XEN_CONSOLE =3D y XEN_INTERFACE_VERSION=3D__XEN_LATEST_INTERFACE_VERSION__ # The following are special: they need support from outside -CONFIG_LIBXENCTRL =3D n CONFIG_LIBXENEVTCHN =3D n CONFIG_LIBXENGNTTAB =3D n CONFIG_LWIP =3D n diff --git a/include/lib.h b/include/lib.h index b40e213..4892320 100644 --- a/include/lib.h +++ b/include/lib.h @@ -170,8 +170,7 @@ void sanity_check(void); #define FTYPE_XENBUS 12 #define FTYPE_GNTMAP 13 #define FTYPE_EVTCHN 14 -#define FTYPE_XC 15 -#define FTYPE_N 16 +#define FTYPE_N 15 #define FTYPE_SPARE 16 =20 typedef int file_read_func(int fd, void *buf, size_t nbytes); diff --git a/lib/sys.c b/lib/sys.c index c327247..52876e0 100644 --- a/lib/sys.c +++ b/lib/sys.c @@ -87,7 +87,6 @@ } =20 #define NOFILE 32 -extern void minios_interface_close_fd(int fd); extern void minios_evtchn_close_fd(int fd); extern void minios_gnttab_close_fd(int fd); =20 @@ -506,11 +505,6 @@ int close(int fd) res =3D lwip_close(files[fd].fd); break; #endif -#ifdef CONFIG_LIBXENCTRL - case FTYPE_XC: - minios_interface_close_fd(fd); - break; -#endif #ifdef CONFIG_LIBXENEVTCHN case FTYPE_EVTCHN: minios_evtchn_close_fd(fd); @@ -729,7 +723,6 @@ static const char *file_types[] =3D { [FTYPE_NONE] =3D "none", [FTYPE_CONSOLE] =3D "console", [FTYPE_XENBUS] =3D "xenbus", - [FTYPE_XC] =3D "ctrl", [FTYPE_EVTCHN] =3D "evtchn", [FTYPE_SOCKET] =3D "socket", [FTYPE_TAP] =3D "net", @@ -1510,12 +1503,6 @@ void *mmap(void *start, size_t length, int prot, int= flags, int fd, off_t offset =20 if (fd =3D=3D -1) return map_zero(n, 1); -#ifdef CONFIG_LIBXENCTRL - else if (files[fd].type =3D=3D FTYPE_XC) { - unsigned long zero =3D 0; - return map_frames_ex(&zero, n, 0, 0, 1, DOMID_SELF, NULL, 0); - } -#endif else if (files[fd].type =3D=3D FTYPE_MEM) { unsigned long first_mfn =3D offset >> PAGE_SHIFT; return map_frames_ex(&first_mfn, n, 0, 1, 1, DOMID_IO, NULL, _PAGE= _PRESENT|_PAGE_RW); --=20 2.26.2