From nobody Thu Oct 30 23:31:26 2025 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=1751443999; cv=none; d=zohomail.com; s=zohoarc; b=lw7jWBQ9EroH/w+IZqdiK7tJY/KJoYsh3YfL573kl3gPw8rLhHqAdoMHnvDANtUh6X0oEpKtzZjlA3yhRbbU07HHL1+BEdlptgn2kgInz2oAESRHun3RkXxyMaUy/Y05XSzIBaMrshChn14zJFeupUonZ2KE5eULIVGDekk7pmE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751443999; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=N4f9gptLjJY0e6N/f33d13mKNX3TplFpE0BIUSgd+yE=; b=mgCrx+goDfDqt3I/FoQWoaJ92ozoGWqP68xl8qYLlUfvqs+SGLcfWnaMhd0u9hoUTF3TWHV0mjraITt4XdGGnDVzMfSjSbQgwJEHQ2nOwijXQ76adNRi0XD2GtW7c+7/R6DL4JjnmyoJxy/GAP92VoLvSSRAgktez7/CHdOuDtk= 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 175144399975353.91703952552825; Wed, 2 Jul 2025 01:13:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030378.1404022 (Exim 4.92) (envelope-from ) id 1uWsaX-0008Ir-U1; Wed, 02 Jul 2025 08:13:05 +0000 Received: by outflank-mailman (output) from mailman id 1030378.1404022; Wed, 02 Jul 2025 08:13:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWsaX-0008Ik-Pd; Wed, 02 Jul 2025 08:13:05 +0000 Received: by outflank-mailman (input) for mailman id 1030378; Wed, 02 Jul 2025 08:13:04 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWsaW-00082Y-5q for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:13:04 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 605beaf1-571c-11f0-a313-13f23c93f187; Wed, 02 Jul 2025 10:13:03 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 43E542118B; Wed, 2 Jul 2025 08:13:03 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1BC0E13A24; Wed, 2 Jul 2025 08:13:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id xWhYBQ/qZGjzSAAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:13:03 +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: 605beaf1-571c-11f0-a313-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751443983; 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=N4f9gptLjJY0e6N/f33d13mKNX3TplFpE0BIUSgd+yE=; b=t7MrFrm0/HDLCcTybXibhpoWM5oUKjxCEPNzzq6FlaGy9g287RDAAaGKRhOfuz2J1d4Nsz HlEVo9DAmC4CYgobgxUXDP8yIIKBVI/jflTHT9ifNgMXRd+oNQ7SzFgK7epfaW6t+cBJ/u o/UOoVYCb0s09NU/ULlKtIvzbfzAs/s= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=t7MrFrm0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751443983; 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=N4f9gptLjJY0e6N/f33d13mKNX3TplFpE0BIUSgd+yE=; b=t7MrFrm0/HDLCcTybXibhpoWM5oUKjxCEPNzzq6FlaGy9g287RDAAaGKRhOfuz2J1d4Nsz HlEVo9DAmC4CYgobgxUXDP8yIIKBVI/jflTHT9ifNgMXRd+oNQ7SzFgK7epfaW6t+cBJ/u o/UOoVYCb0s09NU/ULlKtIvzbfzAs/s= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 01/19] setup: add global pointer for struct hvm_start_info Date: Wed, 2 Jul 2025 10:12:36 +0200 Message-ID: <20250702081254.14383-2-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 43E542118B X-Rspamd-Action: no action X-Spam-Flag: NO X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:dkim,suse.com:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received,2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[suse.com:+] X-Spam-Score: -3.01 X-Spam-Level: X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444002285116600 Content-Type: text/plain; charset="utf-8" Similar to start_info_ptr for PV provide hvm_start_info_ptr for PVH. Add a generic function to set the pointer. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- arch/x86/setup.c | 20 +++++++++++++++++--- include/hypervisor.h | 3 +++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/arch/x86/setup.c b/arch/x86/setup.c index ed28d940..2085ee5c 100644 --- a/arch/x86/setup.c +++ b/arch/x86/setup.c @@ -69,6 +69,11 @@ static inline void sse_init(void) { start_info_t *start_info_ptr; EXPORT_SYMBOL(start_info_ptr); =20 +static void set_info_ptr(start_info_t *ptr) +{ + start_info_ptr =3D ptr; +} + #define hpc_init() =20 shared_info_t *map_shared_info(void) @@ -123,6 +128,17 @@ static void print_start_of_day(void *p) printk(" stack: %p-%p\n", stack, stack + sizeof(stack)); } #else + +/* + * This pointer holds a reference to the hvm_start_info struct. + */ +struct hvm_start_info *hvm_start_info_ptr; + +static void set_info_ptr(struct hvm_start_info *ptr) +{ + hvm_start_info_ptr =3D ptr; +} + static void hpc_init(void) { uint32_t eax, ebx, ecx, edx, base; @@ -176,9 +192,7 @@ arch_init(void *par) { static char hello[] =3D "Bootstrapping...\n"; =20 -#ifdef CONFIG_PARAVIRT - start_info_ptr =3D par; -#endif + set_info_ptr(par); =20 hpc_init(); (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(hello), hello); diff --git a/include/hypervisor.h b/include/hypervisor.h index d199f039..93f1247f 100644 --- a/include/hypervisor.h +++ b/include/hypervisor.h @@ -33,6 +33,9 @@ extern start_info_t *start_info_ptr; =20 #define start_info (*start_info_ptr) #else +#include + +extern struct hvm_start_info *hvm_start_info_ptr; int hvm_get_parameter(int idx, uint64_t *value); int hvm_set_parameter(int idx, uint64_t value); #endif --=20 2.43.0 From nobody Thu Oct 30 23:31:26 2025 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=1751444008; cv=none; d=zohomail.com; s=zohoarc; b=KFdzd70JT4ZS00HlvqN9xd5vcZKZJcCHlNA3DETC1MisDm2cBHl+gZZ/j3te+aes0HuSRn6+snCFzxOPtdBDXnTEuTjrj0U9qqrmT/sjw2oku1fhsMY1k3YNs5/+EM07+wu2M1b6Gf0c3CD/R2CyFMD3WRuyGuJnzbUE4C/3Lms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751444008; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OogoM4iMQHWV+6sWu3sxpe6GFoI8m1ZNv0L6fcMW6nA=; b=iC2CEsdcEOO6WPd/A9wU+BLBmKSS9P+bo2Y15WoZQhKigCQ5JOheCcAmYZVVpTJcE6ZZHmwBdeMkZs0jxE64wIpWDP8msNTUOE5LOJQ1wKS+4Extt/tH4jfI8SAALGHI3QTj/JThrJ1bGYMZ6Kq4W9W9ae+ewVMSfMka/XdAmSs= 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 1751444008781974.2594346406497; Wed, 2 Jul 2025 01:13:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030382.1404041 (Exim 4.92) (envelope-from ) id 1uWsae-0000DR-FH; Wed, 02 Jul 2025 08:13:12 +0000 Received: by outflank-mailman (output) from mailman id 1030382.1404041; Wed, 02 Jul 2025 08:13:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWsae-0000DD-8X; Wed, 02 Jul 2025 08:13:12 +0000 Received: by outflank-mailman (input) for mailman id 1030382; Wed, 02 Jul 2025 08:13:10 +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 1uWsac-00082X-UT for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:13:10 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [2a07:de40:b251:101:10:150:64:1]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6397136f-571c-11f0-b894-0df219b8e170; Wed, 02 Jul 2025 10:13:09 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D47E72117F; Wed, 2 Jul 2025 08:13:08 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id AA54D13A24; Wed, 2 Jul 2025 08:13:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id xuohKBTqZGj8SAAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:13:08 +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: 6397136f-571c-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751443988; 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=OogoM4iMQHWV+6sWu3sxpe6GFoI8m1ZNv0L6fcMW6nA=; b=N0rSvNMB3NiZDLE+mkszMPJA5aAkaURzSnb1wVGxCll7VqckVjuWLESyGNKVCOhL86z5zZ xu6g0JOOd1t1Vw/gx9po/Cs4r8Le3UjhZ4b44aukn9LhuSfvZ02j9qrrI2YmwJHkPbsML4 EebUbhNlFlqzNjyhb9JagEqCLhpaN68= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751443988; 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=OogoM4iMQHWV+6sWu3sxpe6GFoI8m1ZNv0L6fcMW6nA=; b=N0rSvNMB3NiZDLE+mkszMPJA5aAkaURzSnb1wVGxCll7VqckVjuWLESyGNKVCOhL86z5zZ xu6g0JOOd1t1Vw/gx9po/Cs4r8Le3UjhZ4b44aukn9LhuSfvZ02j9qrrI2YmwJHkPbsML4 EebUbhNlFlqzNjyhb9JagEqCLhpaN68= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 02/19] mini-os: kexec: add O_CLOEXEC support Date: Wed, 2 Jul 2025 10:12:37 +0200 Message-ID: <20250702081254.14383-3-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: -2.80 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444010114116600 Content-Type: text/plain; charset="utf-8" Define O_CLOEXEC as a non-zero value and add a kexec callback to cycle over all open files to close them in case O_CLOEXEC was specified when opening the file. This requires the addition of a cloexec boolean in struct file. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- include/fcntl.h | 6 ++++++ include/lib.h | 1 + lib/sys.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/include/fcntl.h b/include/fcntl.h index cc59b3ca..3205daed 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -3,6 +3,9 @@ =20 #ifdef HAVE_LIBC #include_next +#ifndef O_CLOEXEC +#define O_CLOEXEC 0x40000 /* Use newlib's value for WIN32 and CYGWIN. */ +#endif #else =20 /* open/fcntl - O_SYNC is only implemented on blocks devices and on files @@ -25,6 +28,9 @@ #define O_DIRECTORY 0200000 /* must be a directory */ #define O_NOFOLLOW 0400000 /* don't follow links */ #define O_NOATIME 01000000 +#ifndef O_CLOEXEC +#define O_CLOEXEC 02000000 +#endif =20 #define F_DUPFD 0 /* dup */ #define F_GETFD 1 /* get close_on_exec */ diff --git a/include/lib.h b/include/lib.h index de67bab0..ea146496 100644 --- a/include/lib.h +++ b/include/lib.h @@ -174,6 +174,7 @@ extern struct wait_queue_head event_queue; struct file { unsigned int type; bool read; /* maybe available for read */ + bool cloexec; off_t offset; union { int fd; /* Any fd from an upper layer. */ diff --git a/lib/sys.c b/lib/sys.c index 481067f7..7dc236e0 100644 --- a/lib/sys.c +++ b/lib/sys.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -221,6 +222,7 @@ int alloc_fd(unsigned int type) if (files[i].type =3D=3D FTYPE_NONE) { files[i].type =3D type; files[i].offset =3D 0; + files[i].cloexec =3D false; pthread_mutex_unlock(&fd_lock); return i; } @@ -231,6 +233,39 @@ int alloc_fd(unsigned int type) } EXPORT_SYMBOL(alloc_fd); =20 +#ifdef CONFIG_KEXEC +static int kexec_close_files(bool undo) +{ + unsigned int i; + static int closed =3D 0; + + if ( undo ) + { + if ( closed ) + printk("Can't undo closing files!\n"); + closed =3D 0; + + return 0; + } + + pthread_mutex_lock(&fd_lock); + + for ( i =3D 0; i < NOFILE; i++ ) + { + if ( files[i].type !=3D FTYPE_NONE && files[i].cloexec ) + { + close(i); + closed++; + } + } + + pthread_mutex_unlock(&fd_lock); + + return 0; +} +kexec_call(kexec_close_files); +#endif + void close_all_files(void) { int i; @@ -374,6 +409,7 @@ int open(const char *pathname, int flags, ...) struct mount_point *mnt; mode_t mode =3D 0; va_list ap; + int fd; =20 if ( flags & O_CREAT ) { @@ -390,7 +426,13 @@ int open(const char *pathname, int flags, ...) mlen =3D strlen(mnt->path); if ( !strncmp(pathname, mnt->path, mlen) && (pathname[mlen] =3D=3D '/' || pathname[mlen] =3D=3D 0) ) - return mnt->open(mnt, pathname + mlen, flags, mode); + { + fd =3D mnt->open(mnt, pathname + mlen, flags, mode); + if ( fd >=3D 0 && (flags & O_CLOEXEC) ) + files[fd].cloexec =3D true; + + return fd; + } } =20 errno =3D EIO; --=20 2.43.0 From nobody Thu Oct 30 23:31:26 2025 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=1751444017; cv=none; d=zohomail.com; s=zohoarc; b=hTxZ9GCxN5XHPa6/qQvPIH/NX8rYvWVUKWwIqZZQ1qgwMtA+kKve0TeYqzc7gp7bpvAQ+usqs8ujKB23OcivelUob99tnujrIrA1uCixESUiyNPusexE8DDVdJsgNWSFkp3UwmqYSs1F5MV5B7UKbl8OXU6JmqlzrWiuZmIAqJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751444017; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LGW/gk3WVxXGF0g4wh7ZDjVSEfCjF8UjuqgxFwW7rBU=; b=AJC0RwHsiVs0a74yoi9CsVMR3p3iKWdOlMS2yzdvXuIgV8MnTj6Q9WxFHE1empM66SQshHu2+V1qmNkWlZk+DVmfC+J5VN2E8t0YExkSD+V4B2innb264pCu0+nmphA3zCPTq8FOrPT0ozNji29sT1btzubtsmzs/P1BhuD8Ci8= 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 1751444017592992.1583004512929; Wed, 2 Jul 2025 01:13:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030390.1404064 (Exim 4.92) (envelope-from ) id 1uWsam-00010Y-Sk; Wed, 02 Jul 2025 08:13:20 +0000 Received: by outflank-mailman (output) from mailman id 1030390.1404064; Wed, 02 Jul 2025 08:13:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWsam-00010P-PC; Wed, 02 Jul 2025 08:13:20 +0000 Received: by outflank-mailman (input) for mailman id 1030390; Wed, 02 Jul 2025 08:13:20 +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 1uWsam-00082X-2V for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:13:20 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 68ed5144-571c-11f0-b894-0df219b8e170; Wed, 02 Jul 2025 10:13:18 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7222921189; Wed, 2 Jul 2025 08:13:14 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 45A1913A24; Wed, 2 Jul 2025 08:13:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id jeA+DxrqZGgDSQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:13:14 +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: 68ed5144-571c-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751443994; 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=LGW/gk3WVxXGF0g4wh7ZDjVSEfCjF8UjuqgxFwW7rBU=; b=MJBVpMHqpu8cKkaJ8YCM1wr0ucHaY7HYgMgsIa83rTqGBYW/FoUvfFctqetwUWONP3pjkk bv+HZOy5FbEORdnda8SPjQo2MMDc2RCX5TyGk9HYCDjXzfZmbYZIEi3diq412+wMu+lOE8 ADwLeEvdfTYG0kH7/q94Awh/lQ6phOs= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=MJBVpMHq DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751443994; 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=LGW/gk3WVxXGF0g4wh7ZDjVSEfCjF8UjuqgxFwW7rBU=; b=MJBVpMHqpu8cKkaJ8YCM1wr0ucHaY7HYgMgsIa83rTqGBYW/FoUvfFctqetwUWONP3pjkk bv+HZOy5FbEORdnda8SPjQo2MMDc2RCX5TyGk9HYCDjXzfZmbYZIEi3diq412+wMu+lOE8 ADwLeEvdfTYG0kH7/q94Awh/lQ6phOs= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 03/19] mini-os: grants: support populated grant table at boot Date: Wed, 2 Jul 2025 10:12:38 +0200 Message-ID: <20250702081254.14383-4-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 7222921189 X-Rspamd-Action: no action X-Spam-Flag: NO X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:dkim,suse.com:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received,2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[suse.com:+] X-Spam-Score: -3.01 X-Spam-Level: X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444018213116600 Content-Type: text/plain; charset="utf-8" When kexec-ing into a new kernel, the grant table might still have active grants. Support that by not adding populated grant entries to the list of free grant entries. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- gnttab.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gnttab.c b/gnttab.c index 8168ed5d..5b04ab01 100644 --- a/gnttab.c +++ b/gnttab.c @@ -183,11 +183,13 @@ init_gnttab(void) #ifdef GNT_DEBUG memset(inuse, 1, sizeof(inuse)); #endif - for (i =3D NR_RESERVED_ENTRIES; i < NR_GRANT_ENTRIES; i++) - put_free_entry(i); =20 gnttab_table =3D arch_init_gnttab(NR_GRANT_FRAMES); printk("gnttab_table mapped at %p.\n", gnttab_table); + + for (i =3D NR_RESERVED_ENTRIES; i < NR_GRANT_ENTRIES; i++) + if (gnttab_table[i].flags =3D=3D 0) + put_free_entry(i); } =20 void --=20 2.43.0 From nobody Thu Oct 30 23:31:26 2025 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=1751444465; cv=none; d=zohomail.com; s=zohoarc; b=TnA6yJUcpev3E2iFjYGOhKyc3VFKtP1numy25t2hN/adIOgnhETDm4CCgDBAZuZXb+ZIarrxr921AoTNWVZjjkyf+zqEirq2JWGSPm0Osiz7jqp1ApG31LZWaNwEWT4j4/nDDAPLS9090wXNe1HqqWmcsYZrLgmvDKFElg9Xo4o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751444465; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=htojwPjo5A/RDFHxCU3Tp6Z00hTGIFV3R4TmEvlvLDM=; b=BtczKnvc+P8F8rr+rt6iX6ogoGAnAMXATvET7XZaTj9qoluS15WOglQPlp0O6nsSE9fJhedpTpDAl/pcGta/87+ozxrJByRVEOC9M9gOKAiJq9vI12cgTzOSlmjFcZHBb7ZC5daqJp4Lp99cHBiW/MXfOpPK+vb/yt6SbTldhaY= 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 175144446523131.82837465392447; Wed, 2 Jul 2025 01:21:05 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030432.1404102 (Exim 4.92) (envelope-from ) id 1uWshv-0004LQ-Dq; Wed, 02 Jul 2025 08:20:43 +0000 Received: by outflank-mailman (output) from mailman id 1030432.1404102; Wed, 02 Jul 2025 08:20:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWshv-0004LE-9V; Wed, 02 Jul 2025 08:20:43 +0000 Received: by outflank-mailman (input) for mailman id 1030432; Wed, 02 Jul 2025 08:20:42 +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 1uWsaq-00082X-Bm for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:13:24 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6bbef403-571c-11f0-b894-0df219b8e170; Wed, 02 Jul 2025 10:13:22 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 12C702117F; Wed, 2 Jul 2025 08:13:20 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D154A13A24; Wed, 2 Jul 2025 08:13:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id lIe6MR/qZGgKSQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:13:19 +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: 6bbef403-571c-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444000; 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=htojwPjo5A/RDFHxCU3Tp6Z00hTGIFV3R4TmEvlvLDM=; b=sNil9WMRqbOF8i/cIJmCEKpdGC2Y19ZrCU5pJeM5pWZ9nlU78bnsqWJl0bzhaKhg+ascrZ gnY7dJtBfH+C1rVGYZwhKEBR2aFy3CnuZahnuR3JArVYIpGhXAP45D6r2N7UP16xTLwFAY SzsJPYsQO7JP3HhooDfAyuAi2sWK1DY= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=sNil9WMR DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444000; 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=htojwPjo5A/RDFHxCU3Tp6Z00hTGIFV3R4TmEvlvLDM=; b=sNil9WMRqbOF8i/cIJmCEKpdGC2Y19ZrCU5pJeM5pWZ9nlU78bnsqWJl0bzhaKhg+ascrZ gnY7dJtBfH+C1rVGYZwhKEBR2aFy3CnuZahnuR3JArVYIpGhXAP45D6r2N7UP16xTLwFAY SzsJPYsQO7JP3HhooDfAyuAi2sWK1DY= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 04/19] time: unbind VIRQ_TIMER across kexec Date: Wed, 2 Jul 2025 10:12:39 +0200 Message-ID: <20250702081254.14383-5-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 12C702117F X-Rspamd-Action: no action X-Spam-Flag: NO X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from,2a07:de40:b281:106:10:150:64:167:received]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.com:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:dkim,suse.com:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo] X-Spam-Score: -3.01 X-Spam-Level: X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444466666116600 Content-Type: text/plain; charset="utf-8" Deactivate the VIRQ_TIMER event when doing kexec() in order to be able to set it up again in the new kernel. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- arch/x86/time.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/x86/time.c b/arch/x86/time.c index 52916e15..3a2a1d29 100644 --- a/arch/x86/time.c +++ b/arch/x86/time.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include =20 @@ -193,3 +194,16 @@ void fini_time(void) HYPERVISOR_set_timer_op(0); unbind_evtchn(port); } + +#ifdef CONFIG_KEXEC +static int unbind_virq_timer(bool undo) +{ + if ( undo ) + init_time(); + else + fini_time(); + + return 0; +} +kexec_call(unbind_virq_timer); +#endif --=20 2.43.0 From nobody Thu Oct 30 23:31:26 2025 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=1751444503; cv=none; d=zohomail.com; s=zohoarc; b=U1RnmXScI3Gg1z9E6kaneJGbnUr7JfBgRVjKtaS98L34oTUEtZOCVtq0GjVefj0O4X1+0yGMruNqQa1U7Mo2WqFEq0e3oevxhq66wUljSVj2oPhXszgYt/TwU6krIZV28P2mVD4A+0B89Iv2aUyBy65JrcqfjskpWj0fUc1/800= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751444503; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iaDK/56bpA9CrTIegS7gZq6xQHIKshW7HV6CJUhUJck=; b=UMRD/rVM4Zq5GvrC8Md1xqs/Jmxy+YgY7loJ0M9DZcvVSNlazZkD2dx4QDvpgj8QR9Me7+3lmmuGBReGAz9JuEotiMYU/8ru+jkCn1rUcypNDUAzXThzfBzQJWMUoVywYoK1cbbbn+0U8zNn3QjnOaJ+rKpoI8W0PFlwfhDexac= 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 1751444503858388.59938723525704; Wed, 2 Jul 2025 01:21:43 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030535.1404266 (Exim 4.92) (envelope-from ) id 1uWsiY-0002Nr-RC; Wed, 02 Jul 2025 08:21:22 +0000 Received: by outflank-mailman (output) from mailman id 1030535.1404266; Wed, 02 Jul 2025 08:21:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWsiY-0002N3-M2; Wed, 02 Jul 2025 08:21:22 +0000 Received: by outflank-mailman (input) for mailman id 1030535; Wed, 02 Jul 2025 08:21:21 +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 1uWsay-00082Y-0n for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:13:32 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 6fe6f4b7-571c-11f0-a313-13f23c93f187; Wed, 02 Jul 2025 10:13:29 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 92FC91F455; Wed, 2 Jul 2025 08:13:25 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 69C9113A24; Wed, 2 Jul 2025 08:13:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id LYdUGCXqZGgXSQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:13:25 +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: 6fe6f4b7-571c-11f0-a313-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444005; 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=iaDK/56bpA9CrTIegS7gZq6xQHIKshW7HV6CJUhUJck=; b=tR91GiVHHAu6qqBoWTtImiOznLtrDZYh8j3vk+SCrlAHTtoR/OLC6w84DHKi++8OIePwru D2uhZdHJLyRfYxGhKYYFL03+ie4Ztd3WGYT/L33XA1y6jl3odQAU57R3PrRHrTfuawt5y4 qeUgiaP1qq+hbkgA1rE4rkoZaGvjmrM= Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=tR91GiVH DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444005; 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=iaDK/56bpA9CrTIegS7gZq6xQHIKshW7HV6CJUhUJck=; b=tR91GiVHHAu6qqBoWTtImiOznLtrDZYh8j3vk+SCrlAHTtoR/OLC6w84DHKi++8OIePwru D2uhZdHJLyRfYxGhKYYFL03+ie4Ztd3WGYT/L33XA1y6jl3odQAU57R3PrRHrTfuawt5y4 qeUgiaP1qq+hbkgA1rE4rkoZaGvjmrM= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 05/19] mm: refactor init_page_allocator() Date: Wed, 2 Jul 2025 10:12:40 +0200 Message-ID: <20250702081254.14383-6-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 92FC91F455 X-Rspamd-Action: no action X-Spam-Flag: NO X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:dkim,suse.com:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received,2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[suse.com:+] X-Spam-Score: -3.01 X-Spam-Level: X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444505475116600 Content-Type: text/plain; charset="utf-8" Split init_page_allocator() into three functions in order to prepare for sparing some memory from being added to the buddy allocator. Use a function pointer for selecting the function used for handling a memory range, as this will be needed by a future patch. For the same reason make iterate_memory_range() globally visible. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- include/mm.h | 3 ++ mm.c | 111 +++++++++++++++++++++++++++++---------------------- 2 files changed, 66 insertions(+), 48 deletions(-) diff --git a/include/mm.h b/include/mm.h index 0a16d56c..1dc89ddb 100644 --- a/include/mm.h +++ b/include/mm.h @@ -95,4 +95,7 @@ void fini_mm(void); =20 void change_readonly(bool readonly); =20 +void iterate_memory_range(unsigned long min, unsigned long max, + void (*func)(unsigned long, unsigned long)); + #endif /* _MM_H_ */ diff --git a/mm.c b/mm.c index 9236db58..858dc108 100644 --- a/mm.c +++ b/mm.c @@ -150,16 +150,74 @@ static void dequeue_elem(chunk_head_t *elem) elem->next->prev =3D elem->prev; } =20 +static void add_memory_range(unsigned long r_min, unsigned long r_max) +{ + unsigned int i; + unsigned long range; + chunk_head_t *ch; + + printk(" Adding memory range %lx-%lx\n", r_min, r_max); + + /* The buddy lists are addressed in high memory. */ + r_min =3D (unsigned long)to_virt(r_min); + r_max =3D (unsigned long)to_virt(r_max); + range =3D r_max - r_min; + + /* Free up the memory we've been given to play with. */ + map_free(PHYS_PFN(r_min), range >> PAGE_SHIFT); + + while ( range !=3D 0 ) + { + /* + * Next chunk is limited by alignment of min, but also + * must not be bigger than remaining range. + */ + for ( i =3D PAGE_SHIFT; (1UL << (i + 1)) <=3D range; i++ ) + { + if ( r_min & (1UL << i) ) + break; + } + + ch =3D (chunk_head_t *)r_min; + r_min +=3D 1UL << i; + range -=3D 1UL << i; + enqueue_elem(ch, i - PAGE_SHIFT); + } +} + +void iterate_memory_range(unsigned long min, unsigned long max, + void (*func)(unsigned long, unsigned long)) +{ + unsigned int m; + unsigned long r_min, r_max; + + for ( m =3D 0; m < e820_entries; m++ ) + { + if ( e820_map[m].type !=3D E820_RAM ) + continue; + if ( e820_map[m].addr + e820_map[m].size >=3D ULONG_MAX ) + BUG(); + + r_min =3D e820_map[m].addr; + r_max =3D r_min + e820_map[m].size; + if ( r_max <=3D min || r_min >=3D max ) + continue; + if ( r_min < min ) + r_min =3D min; + if ( r_max > max ) + r_max =3D max; + + func(r_min, r_max); + } +} + /* * Initialise allocator, placing addresses [@min,@max] in free pool. * @min and @max are PHYSICAL addresses. */ static void init_page_allocator(unsigned long min, unsigned long max) { - int i, m; - unsigned long range; - unsigned long r_min, r_max; - chunk_head_t *ch; + int i; =20 printk("MM: Initialise page allocator for %lx(%lx)-%lx(%lx)\n", (u_long)to_virt(min), min, (u_long)to_virt(max), max); @@ -182,50 +240,7 @@ static void init_page_allocator(unsigned long min, uns= igned long max) /* All allocated by default. */ memset(mm_alloc_bitmap, ~0, mm_alloc_bitmap_size); =20 - for ( m =3D 0; m < e820_entries; m++ ) - { - if ( e820_map[m].type !=3D E820_RAM ) - continue; - if ( e820_map[m].addr + e820_map[m].size >=3D ULONG_MAX ) - BUG(); - - r_min =3D e820_map[m].addr; - r_max =3D r_min + e820_map[m].size; - if ( r_max <=3D min || r_min >=3D max ) - continue; - if ( r_min < min ) - r_min =3D min; - if ( r_max > max ) - r_max =3D max; - - printk(" Adding memory range %lx-%lx\n", r_min, r_max); - - /* The buddy lists are addressed in high memory. */ - r_min =3D (unsigned long)to_virt(r_min); - r_max =3D (unsigned long)to_virt(r_max); - range =3D r_max - r_min; - - /* Free up the memory we've been given to play with. */ - map_free(PHYS_PFN(r_min), range >> PAGE_SHIFT); - - while ( range !=3D 0 ) - { - /* - * Next chunk is limited by alignment of min, but also - * must not be bigger than remaining range. - */ - for ( i =3D PAGE_SHIFT; (1UL << (i + 1)) <=3D range; i++ ) - { - if ( r_min & (1UL << i) ) - break; - } - - ch =3D (chunk_head_t *)r_min; - r_min +=3D 1UL << i; - range -=3D 1UL << i; - enqueue_elem(ch, i - PAGE_SHIFT); - } - } + iterate_memory_range(min, max, add_memory_range); =20 mm_alloc_bitmap_remap(); } --=20 2.43.0 From nobody Thu Oct 30 23:31:26 2025 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=1751444499; cv=none; d=zohomail.com; s=zohoarc; b=K1WkcdZa8sTifkHwhv/QIQfXy+tv35o7XxVTgsQHTib1HPgIHwHpeeLBH4rNTAvqn44TkoGiMby4981EzZo1qrO5l9nIuz60SDvX3MzLIKt+2MbNwRxB2y+29rHpDEqaj/W2cAfafeUlFCRx8ZQwTHyIMbboZfCpwRg1X+e744Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751444499; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PqeT9QtIJE1Ok+fqszezjXe9WOy8z56eRXWRpRN0vUQ=; b=b6XiZnX8eOPQUKi8hw2j9Mbz2yzyXkSsfVaMAJ4yNXRtqZJVLn+AlMYPWiwtaWl+cIOXpGSSZagakXWFnDaYvRm8n8fzeATzqGAO5SATsNXGu2MZ1awnJxCmbL+zbUkRsg+0JQ2OzT01KZj6rCpEml/avMySxV6KUWiyA83CqJ0= 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 1751444499601658.4020834435037; Wed, 2 Jul 2025 01:21:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030543.1404282 (Exim 4.92) (envelope-from ) id 1uWsic-00031U-AW; Wed, 02 Jul 2025 08:21:26 +0000 Received: by outflank-mailman (output) from mailman id 1030543.1404282; Wed, 02 Jul 2025 08:21: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 1uWsic-000318-6X; Wed, 02 Jul 2025 08:21:26 +0000 Received: by outflank-mailman (input) for mailman id 1030543; Wed, 02 Jul 2025 08:21: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 1uWsaz-00082X-4Q for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:13:33 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7102907b-571c-11f0-b894-0df219b8e170; Wed, 02 Jul 2025 10:13:31 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3F6212117F; Wed, 2 Jul 2025 08:13:31 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 135DA13A24; Wed, 2 Jul 2025 08:13:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id FoE4AyvqZGgfSQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:13:31 +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: 7102907b-571c-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444011; 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=PqeT9QtIJE1Ok+fqszezjXe9WOy8z56eRXWRpRN0vUQ=; b=QrGGKNYL/DWVxxTQCLDbMmIH7WiOgWMb7tx1iOXOjolTiAiQlzDJxRfPweerBktWwhi3Nj Ihh1pzYSvqqSlsaH28aA0oOTozW+Y3GOnU7FG14JRopCWE1kJJpZ9oFZD4P42d+47l0TRi AOKexml5tJYNEP1+Q06QyXLtOnirIiA= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444011; 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=PqeT9QtIJE1Ok+fqszezjXe9WOy8z56eRXWRpRN0vUQ=; b=QrGGKNYL/DWVxxTQCLDbMmIH7WiOgWMb7tx1iOXOjolTiAiQlzDJxRfPweerBktWwhi3Nj Ihh1pzYSvqqSlsaH28aA0oOTozW+Y3GOnU7FG14JRopCWE1kJJpZ9oFZD4P42d+47l0TRi AOKexml5tJYNEP1+Q06QyXLtOnirIiA= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 06/19] mm: don't add module pages to free memory Date: Wed, 2 Jul 2025 10:12:41 +0200 Message-ID: <20250702081254.14383-7-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Flag: NO X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444501445116600 Content-Type: text/plain; charset="utf-8" When initializing the memory allocator, don't add memory pages of modules and the initial boot info structure to the free memory. This is relevant only when running in PVH mode, as in PV mode only memory above the initial page tables is added to free memory, and the module and start_info pages are below the page tables. Signed-off-by: Juergen Gross --- arch/x86/mm.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/mm.h | 1 + mm.c | 21 +++++++++++++- 3 files changed, 101 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm.c b/arch/x86/mm.c index 26ede6f4..7c3c83be 100644 --- a/arch/x86/mm.c +++ b/arch/x86/mm.c @@ -78,6 +78,10 @@ void arch_mm_preinit(void *p) last_free_pfn =3D si->nr_pages; balloon_set_nr_pages(last_free_pfn, last_free_pfn); } + +void check_memory_range(unsigned long *from, unsigned long *to) +{ +} #else #include user_desc gdt[NR_GDT_ENTRIES] =3D @@ -125,6 +129,78 @@ void arch_mm_preinit(void *p) last_free_pfn =3D e820_get_maxpfn(pages); balloon_set_nr_pages(pages, last_free_pfn); } + +static void check_memory_range_conflict(unsigned long *from, unsigned long= *to, + unsigned long chk, unsigned long s= z) +{ + unsigned long chk_end =3D chk + sz; + + if ( *to <=3D chk || *from >=3D chk_end ) + return; + + if ( chk <=3D *from ) + *from =3D (chk_end >=3D *to) ? *to : chk_end; + else + *to =3D chk; +} + +/* Reserved memory ranges not added to free memory. */ +#define MAX_RSV_RANGES 1 +static struct { + unsigned long start; + unsigned long size; +} reserved_range[MAX_RSV_RANGES]; + +void check_memory_range(unsigned long *from, unsigned long *to) +{ + unsigned int m; + struct hvm_modlist_entry *mod; + + for ( m =3D 0; m < MAX_RSV_RANGES && reserved_range[m].size; m++ ) + check_memory_range_conflict(from, to, reserved_range[m].start, + reserved_range[m].size); + + mod =3D (struct hvm_modlist_entry *)(unsigned long) + hvm_start_info_ptr->modlist_paddr; + for ( m =3D 0; m < hvm_start_info_ptr->nr_modules; m++ ) + check_memory_range_conflict(from, to, mod[m].paddr, mod[m].size); +} + +#define max(a, b) ((a) < (b) ? (b) : (a)) + +static void pvh_reserve_start_info(unsigned long *start_pfn) +{ + unsigned long end =3D 0; + unsigned long start =3D (unsigned long)hvm_start_info_ptr; + unsigned long end_pfn; + unsigned int m; + struct hvm_modlist_entry *mod; + char *cmdline; + + mod =3D (void *)(unsigned long)hvm_start_info_ptr->modlist_paddr; + + end =3D max(end, start + sizeof(struct hvm_start_info)); + end =3D max(end, hvm_start_info_ptr->modlist_paddr + + hvm_start_info_ptr->nr_modules * + sizeof(struct hvm_modlist_entry)); + for ( m =3D 0; m < hvm_start_info_ptr->nr_modules; m++ ) + { + cmdline =3D (char *)(unsigned long)mod[m].cmdline_paddr; + if ( cmdline ) + end =3D max(end, (unsigned long)cmdline + strlen(cmdline) + 1); + } + cmdline =3D (char *)(unsigned long)hvm_start_info_ptr->cmdline_paddr; + if ( cmdline ) + end =3D max(end, (unsigned long)cmdline + strlen(cmdline) + 1); + if ( hvm_start_info_ptr->version >=3D 1 ) + end =3D max(end, hvm_start_info_ptr->memmap_paddr + + hvm_start_info_ptr->memmap_entries * + sizeof(struct hvm_memmap_table_entry)); + + end_pfn =3D PFN_UP(end); + if ( end_pfn > *start_pfn ) + *start_pfn =3D end_pfn; +} #endif =20 static const struct { @@ -888,6 +964,10 @@ void arch_init_mm(unsigned long* start_pfn_p, unsigned= long* max_pfn_p) if ( max_pfn >=3D MAX_MEM_SIZE / PAGE_SIZE ) max_pfn =3D MAX_MEM_SIZE / PAGE_SIZE - 1; =20 +#ifndef CONFIG_PARAVIRT + pvh_reserve_start_info(&start_pfn); +#endif + printk(" start_pfn: %lx\n", start_pfn); printk(" max_pfn: %lx\n", max_pfn); =20 diff --git a/include/mm.h b/include/mm.h index 1dc89ddb..995e9862 100644 --- a/include/mm.h +++ b/include/mm.h @@ -74,6 +74,7 @@ static __inline__ int get_order(unsigned long size) =20 void arch_init_demand_mapping_area(void); void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p); +void check_memory_range(unsigned long *from, unsigned long *to); =20 unsigned long allocate_ondemand(unsigned long n, unsigned long alignment); /* map f[i*stride]+i*increment for i in 0..n-1, aligned on alignment pages= */ diff --git a/mm.c b/mm.c index 858dc108..8c41d2f2 100644 --- a/mm.c +++ b/mm.c @@ -185,6 +185,25 @@ static void add_memory_range(unsigned long r_min, unsi= gned long r_max) } } =20 +static void consider_memory_range(unsigned long r_min, unsigned long r_max, + void (*func)(unsigned long, unsigned lon= g)) +{ + unsigned long from =3D r_min; + unsigned long to =3D r_max; + + while ( true ) + { + check_memory_range(&from, &to); + if ( from =3D=3D to ) + return; + + func(from, to); + + from =3D to; + to =3D r_max; + } +} + void iterate_memory_range(unsigned long min, unsigned long max, void (*func)(unsigned long, unsigned long)) { @@ -207,7 +226,7 @@ void iterate_memory_range(unsigned long min, unsigned l= ong max, if ( r_max > max ) r_max =3D max; =20 - func(r_min, r_max); + consider_memory_range(r_min, r_max, func); } } =20 --=20 2.43.0 From nobody Thu Oct 30 23:31:26 2025 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=1751444529; cv=none; d=zohomail.com; s=zohoarc; b=VWUN7St8/E3xj7d5GGjQg1qyr6yzOBoAiaYFwMTY+HICJ1YSGaACh2+h5fi7CFSSTsbq+ajRHv+r9n9YKKXRCLmUfjO5jOgpG655GKD4fTW7JGKexy1+mJLvXZfrjBUjg6VSPAaQEuH4HgugPVu7llu0MH42bZdHi8JbHTf7mjc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751444529; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tdGpyRgE6zFBkEZAGFiUxZVsQXRgwUjyVMbYAPLusAo=; b=L+kYKYaCVThwUAPMO2wM3wgm7D2lJUWuolnOi51aHrzdTMZtK4AA+ivi39LOw3cht1n70EiauxwJabPMTDLF2UBILv8CE+RGNh/TWq3sdqUSDUcSFSv98I7N1ZHZL6NYicnAawNEWS6qh58dkKWldG3ax40FBftQ9A5A474URCw= 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 1751444529196192.24343963554293; Wed, 2 Jul 2025 01:22:09 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030597.1404374 (Exim 4.92) (envelope-from ) id 1uWsj6-0007Y3-OF; Wed, 02 Jul 2025 08:21:56 +0000 Received: by outflank-mailman (output) from mailman id 1030597.1404374; Wed, 02 Jul 2025 08:21:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWsj6-0007Xq-KD; Wed, 02 Jul 2025 08:21:56 +0000 Received: by outflank-mailman (input) for mailman id 1030597; Wed, 02 Jul 2025 08:21:56 +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 1uWsb5-00082X-5A for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:13:39 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7444cc44-571c-11f0-b894-0df219b8e170; Wed, 02 Jul 2025 10:13:37 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D310421175; Wed, 2 Jul 2025 08:13:36 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 9F72A13A24; Wed, 2 Jul 2025 08:13:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id KH5hJTDqZGg3SQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:13:36 +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: 7444cc44-571c-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444016; 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=tdGpyRgE6zFBkEZAGFiUxZVsQXRgwUjyVMbYAPLusAo=; b=WaR0MKyG0M0KAo1/03X7Z9/YBAj/liSQUxDFbcAcLRMtvm/Lpy9u8RY2tEgZsywKHVtM6u qEx8bKBeikJiQ4tkl65SALgmqw2ZqMiwm/eet8fap3dPd8pmHMfiN4dvTVU9dI01mU8FmF IV5yO4o5Fwd9K+4+ZgYX0kzkwVqDN/M= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444016; 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=tdGpyRgE6zFBkEZAGFiUxZVsQXRgwUjyVMbYAPLusAo=; b=WaR0MKyG0M0KAo1/03X7Z9/YBAj/liSQUxDFbcAcLRMtvm/Lpy9u8RY2tEgZsywKHVtM6u qEx8bKBeikJiQ4tkl65SALgmqw2ZqMiwm/eet8fap3dPd8pmHMfiN4dvTVU9dI01mU8FmF IV5yO4o5Fwd9K+4+ZgYX0kzkwVqDN/M= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 07/19] kexec: fix physical addresses in start info data Date: Wed, 2 Jul 2025 10:12:42 +0200 Message-ID: <20250702081254.14383-8-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.com:email,suse.com:mid]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: -2.80 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444529550116600 Content-Type: text/plain; charset="utf-8" The physical addresses in struct hvm_start_info are pointing to the memory where the data is being built instead of the location where it will finally be moved to. Fix that. Fixes: b7994b6409a4 ("mini-os: kexec: build parameters for new kernel") Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- arch/x86/kexec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kexec.c b/arch/x86/kexec.c index fc58473e..d84df42c 100644 --- a/arch/x86/kexec.c +++ b/arch/x86/kexec.c @@ -233,9 +233,9 @@ int kexec_get_entry(const char *cmdline) memset(info, 0, sizeof(*info)); info->magic =3D XEN_HVM_START_MAGIC_VALUE; info->version =3D 1; - info->cmdline_paddr =3D kexec_param_mem + sizeof(*info) + + info->cmdline_paddr =3D kexec_param_loc + sizeof(*info) + e820_entries * sizeof(struct hvm_memmap_table_en= try); - info->memmap_paddr =3D kexec_param_mem + sizeof(*info); + info->memmap_paddr =3D kexec_param_loc + sizeof(*info); info->memmap_entries =3D e820_entries; =20 mmap =3D (struct hvm_memmap_table_entry *)(info + 1); --=20 2.43.0 From nobody Thu Oct 30 23:31:26 2025 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=1751444477; cv=none; d=zohomail.com; s=zohoarc; b=M1UzPgwvCWgf2bk1+58nanVeFgXIOYhK4FTCutISP90VE4eOb/gx1gJ0P0q94mj5+dMeHZCdNO+fWFohx4pySmDs7uqOLTfDHu5Itakg+nV9StXlEITFxNTxHpESg+OsXd3YxFjKhwuAkhL/UQF8NEDdOVN1rQJrrov//Js3sCQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751444477; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VFGHThmdUPo7tU8/k1YjcPPbr+K+PG8BXx4fi06T8E8=; b=hH9nQgx8EGbGas0e4OgQD0+zjb3B8ViHbzMrAfadgmqFGbi32J5ZShf8jNyB9Cs9QJDAxu6HeihOKIjFFU4gZeNr6R1UyLlJiHYoypwIBhf5dNzgmePJpLt61RDkCm7ORJJyx594VCu4dhY43X04sDl6EUxZ272J/q0Jo6Ozvqo= 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 1751444477182580.7192675930786; Wed, 2 Jul 2025 01:21:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030493.1404226 (Exim 4.92) (envelope-from ) id 1uWsiG-0008MW-Ib; Wed, 02 Jul 2025 08:21:04 +0000 Received: by outflank-mailman (output) from mailman id 1030493.1404226; Wed, 02 Jul 2025 08:21: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 1uWsiG-0008La-9H; Wed, 02 Jul 2025 08:21:04 +0000 Received: by outflank-mailman (input) for mailman id 1030493; Wed, 02 Jul 2025 08:21:02 +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 1uWsbD-00082X-U7 for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:13:47 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 79da21dc-571c-11f0-b894-0df219b8e170; Wed, 02 Jul 2025 10:13:46 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 55B5D1F454; Wed, 2 Jul 2025 08:13:42 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2CAEC13A24; Wed, 2 Jul 2025 08:13:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id Pfp7CTbqZGhBSQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:13:42 +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: 79da21dc-571c-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444022; 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=VFGHThmdUPo7tU8/k1YjcPPbr+K+PG8BXx4fi06T8E8=; b=tdvNwrFuYC25cBlRD2W9UnU/lW5P7VQOwsNG3RMXt5GAkHq4KsaTh8t4Tm8OjWNrCXtP68 wWviHOIYRdYnF9OwQae4h0xzvHas6e+ULLL7ydMrQ4l67cBwL4WFfDUUWfw0X1D8yGsriI hPYonJ1fCz/VEjm2DyxFqKDlVSTC5eA= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444022; 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=VFGHThmdUPo7tU8/k1YjcPPbr+K+PG8BXx4fi06T8E8=; b=tdvNwrFuYC25cBlRD2W9UnU/lW5P7VQOwsNG3RMXt5GAkHq4KsaTh8t4Tm8OjWNrCXtP68 wWviHOIYRdYnF9OwQae4h0xzvHas6e+ULLL7ydMrQ4l67cBwL4WFfDUUWfw0X1D8yGsriI hPYonJ1fCz/VEjm2DyxFqKDlVSTC5eA= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 08/19] e820: don't count lapic page as initially reserved Date: Wed, 2 Jul 2025 10:12:43 +0200 Message-ID: <20250702081254.14383-9-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Flag: NO X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444478995116600 Content-Type: text/plain; charset="utf-8" The number of pages marked initially as reserved in the memory map are counted to be allocated, as they are normally populated by Xen tools for e.g. xenbus and console ring pages. This is wrong in case the lapic page is marked as reserved in the memory map, as there is never memory allocated for a lapic. So when finding the lapic page to be marked as reserved, don't add it to the number of reserved pages. Fixes: 9b87429d2864 ("mini-os: fix number of pages for PVH") Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- e820.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/e820.c b/e820.c index 49b16878..876d55b1 100644 --- a/e820.c +++ b/e820.c @@ -275,7 +275,10 @@ static void e820_sanitize(void) e820_initial_reserved_pfns +=3D e820_map[i].size / PAGE_SIZE; if ( e820_map[i].addr <=3D LAPIC_ADDRESS && e820_map[i].addr + e820_map[i].size > LAPIC_ADDRESS ) + { found_lapic =3D true; + e820_initial_reserved_pfns--; + } } } =20 --=20 2.43.0 From nobody Thu Oct 30 23:31:26 2025 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=1751444478; cv=none; d=zohomail.com; s=zohoarc; b=UZFlQEuN1j38yHilw1i+8qmwbxZRZe3jmG5r0dtOs6b1HdoTYpL0NxSo8EUPKkbw8qE0x8mtGtOXKJQXmctpqsWRIPCBhRO5F919e3Dle/gFYkOMcaESGgMT+ul09G8gJTd+kDFSaI33IfwZUgZ35yzUllI2BIfbxEKeUxzeS2s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751444478; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=uwLSYgMVcboUpduICczAWr7hs1RsmqCqfe1jLSr8ytE=; b=fQ2jV/14vTKME1y/lVSd9cTJF/JKBNZQWQrJ2zeFEEwUmtxn7UTPja2r/YTAR5wusC/2Tba7YyQJ/V6VZT8xUTkjiDgfYgOpA24Cezs1jP1qodhXEmaOWEePzcjKBHnLNAvRxLsXp3z3vOOANX7fhoziq09dZ0aqtZS/2HbahzA= 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 175144447846797.13071738306019; Wed, 2 Jul 2025 01:21:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030480.1404212 (Exim 4.92) (envelope-from ) id 1uWsiC-0007oZ-SN; Wed, 02 Jul 2025 08:21:00 +0000 Received: by outflank-mailman (output) from mailman id 1030480.1404212; Wed, 02 Jul 2025 08:21:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWsiC-0007nv-MJ; Wed, 02 Jul 2025 08:21:00 +0000 Received: by outflank-mailman (input) for mailman id 1030480; Wed, 02 Jul 2025 08:20:59 +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 1uWsbK-00082X-QZ for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:13:54 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [2a07:de40:b251:101:10:150:64:1]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7dded57e-571c-11f0-b894-0df219b8e170; Wed, 02 Jul 2025 10:13:53 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DF39421182; Wed, 2 Jul 2025 08:13:47 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B3D4113A54; Wed, 2 Jul 2025 08:13:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id BItmKjvqZGhJSQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:13:47 +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: 7dded57e-571c-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444027; 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=uwLSYgMVcboUpduICczAWr7hs1RsmqCqfe1jLSr8ytE=; b=r7oc77bfmJHkkSzUx4K3TRfIU50j9Jj7KAhiDiExMV+qTsjZIb6ZBdKjecTxEBC5V4fRFa ppqgKf36/Ya7m2NvY9rUe5fPaQ5RI892qfK78i4iQvgyq5sFCO3J/bhRll9izfEGLFHxfO 4R1OjJGloBjUZhJ4X4LDsxo5vpuFnhc= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444027; 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=uwLSYgMVcboUpduICczAWr7hs1RsmqCqfe1jLSr8ytE=; b=r7oc77bfmJHkkSzUx4K3TRfIU50j9Jj7KAhiDiExMV+qTsjZIb6ZBdKjecTxEBC5V4fRFa ppqgKf36/Ya7m2NvY9rUe5fPaQ5RI892qfK78i4iQvgyq5sFCO3J/bhRll9izfEGLFHxfO 4R1OjJGloBjUZhJ4X4LDsxo5vpuFnhc= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 09/19] kexec: restructure building the start info data Date: Wed, 2 Jul 2025 10:12:44 +0200 Message-ID: <20250702081254.14383-10-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Flag: NO X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444480933116600 Content-Type: text/plain; charset="utf-8" Instead of setting most of the struct hvm_start_info fields first and then building the leaf data, restructure kexec_get_entry() by using an opaque "next" pointer where the next leaf data will be stored and handle that leaf data together with the associated hvm_start_info fields. This will make it easier to add new data items without having to rewrite large portions of the function. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- arch/x86/kexec.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/arch/x86/kexec.c b/arch/x86/kexec.c index d84df42c..3e3b64e2 100644 --- a/arch/x86/kexec.c +++ b/arch/x86/kexec.c @@ -215,6 +215,7 @@ void kexec_set_param_loc(const char *cmdline) =20 int kexec_get_entry(const char *cmdline) { + void *next; struct hvm_start_info *info; struct hvm_memmap_table_entry *mmap; unsigned int order; @@ -229,16 +230,17 @@ int kexec_get_entry(const char *cmdline) if ( !kexec_param_mem ) return ENOMEM; =20 - info =3D (struct hvm_start_info *)kexec_param_mem; + next =3D (void *)kexec_param_mem; + + info =3D next; memset(info, 0, sizeof(*info)); info->magic =3D XEN_HVM_START_MAGIC_VALUE; info->version =3D 1; - info->cmdline_paddr =3D kexec_param_loc + sizeof(*info) + - e820_entries * sizeof(struct hvm_memmap_table_en= try); - info->memmap_paddr =3D kexec_param_loc + sizeof(*info); - info->memmap_entries =3D e820_entries; + next =3D info + 1; =20 - mmap =3D (struct hvm_memmap_table_entry *)(info + 1); + mmap =3D next; + info->memmap_paddr =3D kexec_param_loc + (unsigned long)next - kexec_p= aram_mem; + info->memmap_entries =3D e820_entries; for ( i =3D 0; i < e820_entries; i++ ) { mmap->addr =3D e820_map[i].addr; @@ -246,8 +248,10 @@ int kexec_get_entry(const char *cmdline) mmap->type =3D e820_map[i].type; mmap++; } + next =3D mmap; =20 - strcpy((char *)mmap, cmdline); + info->cmdline_paddr =3D kexec_param_loc + (unsigned long)next - kexec_= param_mem; + strcpy(next, cmdline); =20 if ( kexec_add_action(KEXEC_COPY, to_virt(kexec_param_loc), info, kexec_param_size) ) --=20 2.43.0 From nobody Thu Oct 30 23:31:26 2025 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=1751444510; cv=none; d=zohomail.com; s=zohoarc; b=Nn9X/N0Jv2qY9rniW34E0cyjouF1gAyOg91oXQ9u1EN8uMX7+VSENp7BsEaMgWdEW9DmQ3Oju65MX73P/wS3AvShd0j3x+Zsjt6loCakglnz89ig/NaXg4M4h47X3kKrSA0SLGUS+ZtgyTX4eIu0IBWmuTKQpFayx2bNXz7kazk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751444510; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=s/i8n5z/NUez13m+U8EQbdRMUJ37I2u8cMr138p+cB8=; b=alxJRjN0jprNFsmGFYXmPUJlKv/eTeadjZ/lCLMuUFajgZl9W/7KL+Gxj2YzVPbrMxnuYJPoZZ/pgDLMtlRicovPj0XJxWx+MLY6tagepBpguePgYB7+yeelo4EuER09BiHhRIE0mKW2f6K5bOELA07rJ5JT+F5VyUz/CcpMEpo= 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 1751444510231697.3960911407453; Wed, 2 Jul 2025 01:21:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030555.1404297 (Exim 4.92) (envelope-from ) id 1uWsii-0003gV-Qq; Wed, 02 Jul 2025 08:21:32 +0000 Received: by outflank-mailman (output) from mailman id 1030555.1404297; Wed, 02 Jul 2025 08:21:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWsii-0003fj-Hs; Wed, 02 Jul 2025 08:21:32 +0000 Received: by outflank-mailman (input) for mailman id 1030555; Wed, 02 Jul 2025 08:21:31 +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 1uWsbL-00082X-Qp for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:13:55 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7e2e27b6-571c-11f0-b894-0df219b8e170; Wed, 02 Jul 2025 10:13:53 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 70F181F452; Wed, 2 Jul 2025 08:13:53 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 46F0C13A24; Wed, 2 Jul 2025 08:13:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id Yj32D0HqZGhSSQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:13:53 +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: 7e2e27b6-571c-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444033; 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=s/i8n5z/NUez13m+U8EQbdRMUJ37I2u8cMr138p+cB8=; b=aioiIU2BAhP98zrkqlWpEjTluzk9qUbZo3IbIMGOa5Bjjzr3rN97rZdwC58T3r3cfSAxLq NynNOR6iugpm0TAYGCc9rsl9+DPsTX4Y4W/tylV5KE6I9Tq1RAE7UndgNU281iuRS1nmZw jY5fpRckGvmJwo+y+Z7hZtR42t41A/c= Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=aioiIU2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444033; 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=s/i8n5z/NUez13m+U8EQbdRMUJ37I2u8cMr138p+cB8=; b=aioiIU2BAhP98zrkqlWpEjTluzk9qUbZo3IbIMGOa5Bjjzr3rN97rZdwC58T3r3cfSAxLq NynNOR6iugpm0TAYGCc9rsl9+DPsTX4Y4W/tylV5KE6I9Tq1RAE7UndgNU281iuRS1nmZw jY5fpRckGvmJwo+y+Z7hZtR42t41A/c= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 10/19] e820: use special type for software reserved memory Date: Wed, 2 Jul 2025 10:12:45 +0200 Message-ID: <20250702081254.14383-11-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.com:dkim,suse.com:mid,suse.com:email]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from,2a07:de40:b281:106:10:150:64:167:received]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[suse.com:+] X-Spam-Level: X-Spam-Flag: NO X-Rspamd-Queue-Id: 70F181F452 X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: -3.01 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444511370116600 Content-Type: text/plain; charset="utf-8" For memory areas used to map foreign domain memory Mini-OS is using the type E820_RESERVED in the memory map today. This is causing problems with kexec, as the new kernel should not see those areas in the memory map. Unfortunately the sequence of actions for calculating the size of the memory map and the removal of those reserved areas can't easily be adjusted to do the removal first, so another way must be used to avoid passing those reserved areas to the new kernel. Instead of using the type E820_RESERVED, which might be used for other pages as well, just use a new type. Areas with that new type can easily be filtered out when building the memory map for the new kernel. Introduce the type E820_TYPE_SOFT_RESERVED with the same value as the Linux kernel is using for the same purpose. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- arch/x86/kexec.c | 4 +++- e820.c | 8 ++++---- include/e820.h | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/x86/kexec.c b/arch/x86/kexec.c index 3e3b64e2..804e7b6d 100644 --- a/arch/x86/kexec.c +++ b/arch/x86/kexec.c @@ -240,14 +240,16 @@ int kexec_get_entry(const char *cmdline) =20 mmap =3D next; info->memmap_paddr =3D kexec_param_loc + (unsigned long)next - kexec_p= aram_mem; - info->memmap_entries =3D e820_entries; for ( i =3D 0; i < e820_entries; i++ ) { + if ( e820_map[i].type =3D=3D E820_TYPE_SOFT_RESERVED ) + continue; mmap->addr =3D e820_map[i].addr; mmap->size =3D e820_map[i].size; mmap->type =3D e820_map[i].type; mmap++; } + info->memmap_entries =3D mmap - (struct hvm_memmap_table_entry *)next; next =3D mmap; =20 info->cmdline_paddr =3D kexec_param_loc + (unsigned long)next - kexec_= param_mem; diff --git a/e820.c b/e820.c index 876d55b1..d8cfb1f4 100644 --- a/e820.c +++ b/e820.c @@ -367,8 +367,8 @@ unsigned long e820_get_reserved_pfns(int pages) for ( i =3D 0; i < e820_entries && e820_map[i].addr < last + needed; i= ++ ) last =3D e820_map[i].addr + e820_map[i].size; =20 - if ( i =3D=3D 0 || e820_map[i - 1].type !=3D E820_RESERVED ) - e820_insert_entry_at(i, last, needed, E820_RESERVED); + if ( i =3D=3D 0 || e820_map[i - 1].type !=3D E820_TYPE_SOFT_RESERVED ) + e820_insert_entry_at(i, last, needed, E820_TYPE_SOFT_RESERVED); else e820_map[i - 1].size +=3D needed; =20 @@ -385,7 +385,7 @@ void e820_put_reserved_pfns(unsigned long start_pfn, in= t pages) i < e820_entries && addr >=3D e820_map[i].addr + e820_map[i].siz= e; i++ ); =20 - BUG_ON(i =3D=3D e820_entries || e820_map[i].type !=3D E820_RESERVED || + BUG_ON(i =3D=3D e820_entries || e820_map[i].type !=3D E820_TYPE_SOFT_R= ESERVED || addr + size > e820_map[i].addr + e820_map[i].size); =20 if ( addr =3D=3D e820_map[i].addr ) @@ -405,7 +405,7 @@ void e820_put_reserved_pfns(unsigned long start_pfn, in= t pages) =20 e820_insert_entry_at(i + 1, addr + size, e820_map[i].addr + e820_map[i].size - addr - size, - E820_RESERVED); + E820_TYPE_SOFT_RESERVED); e820_map[i].size =3D addr - e820_map[i].addr; } #endif diff --git a/include/e820.h b/include/e820.h index ffa15aa9..ad5657ff 100644 --- a/include/e820.h +++ b/include/e820.h @@ -39,6 +39,8 @@ #define E820_DISABLED 6 #define E820_PMEM 7 #define E820_TYPES 8 +/* Memory reserved for Mini-OS internal purpose. */ +#define E820_TYPE_SOFT_RESERVED 0xefffffff =20 struct __packed e820entry { uint64_t addr; --=20 2.43.0 From nobody Thu Oct 30 23:31:26 2025 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=1751444458; cv=none; d=zohomail.com; s=zohoarc; b=EbJ3vojUxouBRDDiFDIu3MlbYAxFK/Eoho+77tCzoggCTYZtUPMio0GBqYaWOgkrdgZjgomnDIxdzNVRF9Q4Y1GkErtoYOgECzr60yj90cxiVbxJKPn2Iuwman1BUQ+XLd8vFo2bLSkXrIPJU9zLPCZZqcyuIauQOjJUqX+XCfw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751444458; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZRCeeHYAZX30u0CV5OETlVsm4bHFhhMFufeH4FMn+N0=; b=jl2xVh1Bite7+vFzCraLLVNbKIF2uDVMQIwJVjDh/Rod4EiD5BYAe0AhLatP/h4K3PBR7nBrJhZlnoGooOgqhNAPM6bsNU/NiCwcliI0R/I8ScnqMHVnu/13tGTFuapdZyi8n8EYahOvo5bVAKDmBg5MiPoqY4AWTvURzRmu0To= 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 1751444458610438.72923739980763; Wed, 2 Jul 2025 01:20:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030433.1404106 (Exim 4.92) (envelope-from ) id 1uWshv-0004NI-Ll; Wed, 02 Jul 2025 08:20:43 +0000 Received: by outflank-mailman (output) from mailman id 1030433.1404106; Wed, 02 Jul 2025 08:20:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWshv-0004MX-GD; Wed, 02 Jul 2025 08:20:43 +0000 Received: by outflank-mailman (input) for mailman id 1030433; Wed, 02 Jul 2025 08:20:42 +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 1uWsbQ-00082X-QU for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:14:00 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8188ff02-571c-11f0-b894-0df219b8e170; Wed, 02 Jul 2025 10:13:59 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 047E51F76B; Wed, 2 Jul 2025 08:13:59 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CF10213A24; Wed, 2 Jul 2025 08:13:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id mGctMUbqZGhbSQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:13:58 +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: 8188ff02-571c-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444039; 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=ZRCeeHYAZX30u0CV5OETlVsm4bHFhhMFufeH4FMn+N0=; b=dpMRKraZzMJzlGpf14sfq/88yWICScoZbVVspc/xbXT70FZ6rxyYuH04YJ+B06g3u5ACSI SWp4voOugJ9WgumnG1awE6Xg+ZZ+ODkDFpOeeoMNu88L0HbTjsGKnFvN4IWYOLM+/Arghf 6GM/VbrJJlYAlQeE+A3MyX56InCwWpE= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444039; 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=ZRCeeHYAZX30u0CV5OETlVsm4bHFhhMFufeH4FMn+N0=; b=dpMRKraZzMJzlGpf14sfq/88yWICScoZbVVspc/xbXT70FZ6rxyYuH04YJ+B06g3u5ACSI SWp4voOugJ9WgumnG1awE6Xg+ZZ+ODkDFpOeeoMNu88L0HbTjsGKnFvN4IWYOLM+/Arghf 6GM/VbrJJlYAlQeE+A3MyX56InCwWpE= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 11/19] mini-os: config: add support for config items with numerical values Date: Wed, 2 Jul 2025 10:12:46 +0200 Message-ID: <20250702081254.14383-12-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Flag: NO X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444460681116600 Content-Type: text/plain; charset="utf-8" Add support for a Mini-OS config file containing config items with numerical values, e.g. CONFIG_FOO=3D7. Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich --- Config.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Config.mk b/Config.mk index e2afb1b4..b9675e61 100644 --- a/Config.mk +++ b/Config.mk @@ -178,6 +178,7 @@ endif # CONFIG-y contains all items defaulting to "y" # CONFIG-n contains all items defaulting to "n" # CONFIG-x contains all items being calculated if not set explicitly +# CONFIG-val-y contains all items with numerical values, defaulting to 0 CONFIG-y +=3D CONFIG_START_NETWORK CONFIG-y +=3D CONFIG_SPARSE_BSS CONFIG-y +=3D CONFIG_BLKFRONT @@ -219,6 +220,8 @@ CONFIG-$(lwip) +=3D CONFIG_LWIP $(foreach i,$(CONFIG-y),$(eval $(i) ?=3D y)) $(foreach i,$(CONFIG-n),$(eval $(i) ?=3D n)) =20 +$(foreach i,$(CONFIG-val-y),$(eval $(i) ?=3D 0)) + CONFIG-x +=3D CONFIG_LIBXS CONFIG_LIBXS ?=3D $(CONFIG_XENBUS) =20 @@ -226,6 +229,7 @@ CONFIG-all :=3D $(CONFIG-y) $(CONFIG-n) $(CONFIG-x) =20 # Export config items as compiler directives $(foreach i,$(CONFIG-all),$(eval DEFINES-$($(i)) +=3D -D$(i))) +$(foreach i,$(CONFIG-val-y),$(eval DEFINES-y +=3D -D$(i)=3D$($(i)))) =20 DEFINES-y +=3D -D__XEN_INTERFACE_VERSION__=3D$(XEN_INTERFACE_VERSION) =20 --=20 2.43.0 From nobody Thu Oct 30 23:31:26 2025 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=1751444526; cv=none; d=zohomail.com; s=zohoarc; b=ItcAxr2StD5qoBkDANC+FgYAchxrwZt7PqfUVD1k926zhJWubich5O0EGVnautBNfdf6WWAZ7iSCIHvn/sGq9mpDcg/VQpkTl6vQ7RjhgmYSL4aW6ecqYwwYvdj/aJiFk5INSekpIzOOfQME1VYaaBD3Dp36Kb0hsXxmReOZNu0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751444526; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=rhVOHkoDR7DK9kEudYFjk42y/LOmgxRrKdj918bopVw=; b=hGlx5WDdRxdPchWAWnhLdhw+yAmuutOzKH2ODORVb1OHZDZPqSBmK7N7HnvxtQIPxRzCj+WcpgCib8Hg6Rns50avqDW2Qs6EmtIfCZq3mnq/QQ5FFH+07j4gB8/qRKCZumVJZeZ7UxyYVtXImU8iR5GrVnHBnN7ssyRhBU/aP7M= 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 175144452664264.26762573763813; Wed, 2 Jul 2025 01:22:06 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030584.1404354 (Exim 4.92) (envelope-from ) id 1uWsix-00066e-5T; Wed, 02 Jul 2025 08:21:47 +0000 Received: by outflank-mailman (output) from mailman id 1030584.1404354; Wed, 02 Jul 2025 08:21:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWsiw-00064a-VT; Wed, 02 Jul 2025 08:21:46 +0000 Received: by outflank-mailman (input) for mailman id 1030584; Wed, 02 Jul 2025 08:21:45 +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 1uWsbV-00082Y-L9 for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:14:05 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 84e1cadb-571c-11f0-a313-13f23c93f187; Wed, 02 Jul 2025 10:14:05 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 8CB271F445; Wed, 2 Jul 2025 08:14:04 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 63B2B13A24; Wed, 2 Jul 2025 08:14:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id HxfxFkzqZGhhSQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:14:04 +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: 84e1cadb-571c-11f0-a313-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444044; 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=rhVOHkoDR7DK9kEudYFjk42y/LOmgxRrKdj918bopVw=; b=jkRNzMt28TxzuaBTSnR9Rmo5R+TMVmodcG8ICyYB0Zk1UOOZS07w1YMSKguZS3jt7XKZ66 JOIgH69IQl+osp7N3qYtGrcIPwIzb+1+VMEuRzHHCM983bpGMjP6/PRi+/+s58tnGQRN9I A46c8DJtfGZyYdvG9oeareiQW3a9qco= Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=jkRNzMt2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444044; 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=rhVOHkoDR7DK9kEudYFjk42y/LOmgxRrKdj918bopVw=; b=jkRNzMt28TxzuaBTSnR9Rmo5R+TMVmodcG8ICyYB0Zk1UOOZS07w1YMSKguZS3jt7XKZ66 JOIgH69IQl+osp7N3qYtGrcIPwIzb+1+VMEuRzHHCM983bpGMjP6/PRi+/+s58tnGQRN9I A46c8DJtfGZyYdvG9oeareiQW3a9qco= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 12/19] mini-os: kexec: add support for handing over some memory across kexec Date: Wed, 2 Jul 2025 10:12:47 +0200 Message-ID: <20250702081254.14383-13-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 8CB271F445 X-Rspamd-Action: no action X-Spam-Flag: NO X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:dkim,suse.com:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from,2a07:de40:b281:106:10:150:64:167:received]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[suse.com:+] X-Spam-Score: -3.01 X-Spam-Level: X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444527795116600 Content-Type: text/plain; charset="utf-8" Especially for support of Xenstore-stubdom live update some memory must be handed over to the new kernel without moving it around: as the 9pfs device used for storing and retrieving the state of Xenstore needs to be kept operational across kexec (it can't be reopened due to Xenstore not being available without access to the device), the ring pages need to be accessible via active grants by the backend all the time. Add the basic support for that by reserving a pre-defined number of memory pages at the top of the memory. This memory area will be handed over to the new kernel via specifying it as a module in struct hvm_start_info. The contents of the memory area are described via a generic table of contents in the last page of the memory. Signed-off-by: Juergen Gross --- Config.mk | 2 ++ arch/x86/kexec.c | 77 +++++++++++++++++++++++++++++++++++++++++++ arch/x86/mm.c | 18 ++++++++++ arch/x86/setup.c | 28 ++++++++++++++++ include/kernel.h | 1 + include/kexec.h | 45 +++++++++++++++++++++++++ include/x86/arch_mm.h | 1 + kexec.c | 3 ++ mm.c | 6 ++++ 9 files changed, 181 insertions(+) diff --git a/Config.mk b/Config.mk index b9675e61..0e4e86d8 100644 --- a/Config.mk +++ b/Config.mk @@ -220,6 +220,8 @@ CONFIG-$(lwip) +=3D CONFIG_LWIP $(foreach i,$(CONFIG-y),$(eval $(i) ?=3D y)) $(foreach i,$(CONFIG-n),$(eval $(i) ?=3D n)) =20 +CONFIG-val-$(CONFIG_KEXEC) +=3D CONFIG_KEXEC_MODULE_PAGES + $(foreach i,$(CONFIG-val-y),$(eval $(i) ?=3D 0)) =20 CONFIG-x +=3D CONFIG_LIBXS diff --git a/arch/x86/kexec.c b/arch/x86/kexec.c index 804e7b6d..7fb98473 100644 --- a/arch/x86/kexec.c +++ b/arch/x86/kexec.c @@ -201,10 +201,73 @@ static unsigned long kexec_param_loc; static unsigned int kexec_param_size; static unsigned long kexec_param_mem; =20 +static struct kexec_module *kexec_check_module(void) +{ + unsigned long mod_size; + unsigned long mod; + struct kexec_module *module_ptr; + + mod =3D get_module(&mod_size); + if ( !mod ) + return NULL; + /* Size must be a multiple of PAGE_SIZE. */ + if ( mod_size & ~PAGE_MASK ) + return NULL; + + /* Kxec module description is at start of the last page of the module.= */ + module_ptr =3D (void *)(mod + mod_size - (unsigned long)PAGE_SIZE); + + /* Check eye catcher. */ + if ( memcmp(module_ptr->eye_catcher, KEXECMOD_EYECATCHER, + sizeof(module_ptr->eye_catcher)) ) + return NULL; + if ( module_ptr->n_pages !=3D (mod_size >> PAGE_SHIFT) - 1 ) + return NULL; + + return module_ptr; +} + +static void get_mod_addr(unsigned long from, unsigned long to) +{ + unsigned long size =3D PFN_PHYS(CONFIG_KEXEC_MODULE_PAGES); + + if ( to - from >=3D size && to - size > kexec_mod_start ) + kexec_mod_start =3D to - size; +} + +#define min(a, b) ((a) < (b) ? (a) : (b)) +void kexec_module(unsigned long start_pfn, unsigned long max_pfn) +{ + /* Reuse already existing kexec module. */ + mod_ptr =3D kexec_check_module(); + if ( !mod_ptr && CONFIG_KEXEC_MODULE_PAGES ) + { + max_pfn =3D min(max_pfn, PHYS_PFN(0xffffffff)); + + iterate_memory_range(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn), + get_mod_addr); + BUG_ON(!kexec_mod_start); + + mod_ptr =3D (void *)(kexec_mod_start + + ((CONFIG_KEXEC_MODULE_PAGES - 1) << PAGE_SHIFT)= ); + memset(mod_ptr, 0, PAGE_SIZE); + memcpy(mod_ptr->eye_catcher, KEXECMOD_EYECATCHER, + sizeof(mod_ptr->eye_catcher)); + mod_ptr->n_pages =3D CONFIG_KEXEC_MODULE_PAGES - 1; + memset(mod_ptr->pg2rec, KEXECMOD_PG_FREE, mod_ptr->n_pages); + mod_ptr->recs_off =3D sizeof(struct kexec_module) + + CONFIG_KEXEC_MODULE_PAGES + (mod_ptr->n_pages = & 1); + + set_reserved_range(kexec_mod_start, (unsigned long)mod_ptr + PAGE_= SIZE); + } +} + void kexec_set_param_loc(const char *cmdline) { kexec_param_size =3D sizeof(struct hvm_start_info); kexec_param_size +=3D e820_entries * sizeof(struct hvm_memmap_table_en= try); + if ( mod_ptr ) + kexec_param_size +=3D sizeof(struct hvm_modlist_entry); kexec_param_size +=3D strlen(cmdline) + 1; =20 kexec_last_addr =3D (kexec_last_addr + 7) & ~7UL; @@ -218,6 +281,7 @@ int kexec_get_entry(const char *cmdline) void *next; struct hvm_start_info *info; struct hvm_memmap_table_entry *mmap; + struct hvm_modlist_entry *mod; unsigned int order; unsigned int i; =20 @@ -252,6 +316,19 @@ int kexec_get_entry(const char *cmdline) info->memmap_entries =3D mmap - (struct hvm_memmap_table_entry *)next; next =3D mmap; =20 + if ( mod_ptr ) + { + mod =3D next; + memset(mod, 0, sizeof(*mod)); + info->nr_modules =3D 1; + info->modlist_paddr =3D kexec_param_loc + + (unsigned long)next - kexec_param_mem; + mod->paddr =3D kexec_mod_start; + mod->size =3D PFN_PHYS(mod_ptr->n_pages + 1); + mod->cmdline_paddr =3D 0; + next =3D mod + 1; + } + info->cmdline_paddr =3D kexec_param_loc + (unsigned long)next - kexec_= param_mem; strcpy(next, cmdline); =20 diff --git a/arch/x86/mm.c b/arch/x86/mm.c index 7c3c83be..bdff38fd 100644 --- a/arch/x86/mm.c +++ b/arch/x86/mm.c @@ -151,6 +151,24 @@ static struct { unsigned long size; } reserved_range[MAX_RSV_RANGES]; =20 +void set_reserved_range(unsigned long start, unsigned long end) +{ + unsigned int i; + + for ( i =3D 0; i < MAX_RSV_RANGES; i++ ) + { + if ( reserved_range[i].size ) + continue; + + reserved_range[i].start =3D start; + reserved_range[i].size =3D end - start; + + return; + } + + BUG(); +} + void check_memory_range(unsigned long *from, unsigned long *to) { unsigned int m; diff --git a/arch/x86/setup.c b/arch/x86/setup.c index 2085ee5c..299ff8c7 100644 --- a/arch/x86/setup.c +++ b/arch/x86/setup.c @@ -127,6 +127,13 @@ static void print_start_of_day(void *p) printk(" cmd_line: %s\n", cmdline); printk(" stack: %p-%p\n", stack, stack + sizeof(stack)); } + +unsigned long get_module(unsigned long *size) +{ + *size =3D start_info_ptr->mod_len; + + return start_info_ptr->mod_start; +} #else =20 /* @@ -182,6 +189,27 @@ static void print_start_of_day(void *p) printk(" stack: %p-%p\n", stack, stack + sizeof(stack)); arch_print_memmap(); } + +unsigned long get_module(unsigned long *size) +{ + struct hvm_modlist_entry *mod; + + if ( !hvm_start_info_ptr->nr_modules ) + return 0; + + if ( hvm_start_info_ptr->nr_modules > 1 ) + { + printk("get_module() called with more than 1 module present\n"); + printk("First module data returned\n"); + } + + mod =3D (struct hvm_modlist_entry *)(unsigned long) + hvm_start_info_ptr->modlist_paddr; + + *size =3D mod->size; + + return mod->paddr; +} #endif =20 /* diff --git a/include/kernel.h b/include/kernel.h index 161d7571..e11b04cf 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -10,5 +10,6 @@ void post_suspend(int canceled); void do_exit(void) __attribute__((noreturn)); void arch_do_exit(void); void stop_kernel(void); +unsigned long get_module(unsigned long *size); =20 #endif /* _KERNEL_H_ */ diff --git a/include/kexec.h b/include/kexec.h index b89c3000..0200005f 100644 --- a/include/kexec.h +++ b/include/kexec.h @@ -2,6 +2,48 @@ #define _KEXEC_H #include =20 +/* + * Kexec module used to hand over memory across kexec(). + * + * This is an ABI which should be modified only in a compatible way. + * struct kexec_module is located at the start of the last page of the mod= ule. + * + * The module can contain data/pages of multiple users. Each user has an o= wn + * record which layout is depending on the user. Records are linked via a = table + * of record offsets. + * + * All admin data (struct kexec_module, record offset table and records) m= ust + * fit into the last page of the module. + */ +struct kexec_module { + uint8_t eye_catcher[8]; +#define KEXECMOD_EYECATCHER "KexecMem" + uint16_t n_pages; /* Number of allocatable pages in the module. = */ + uint16_t n_records; /* Size of record table (max. 255). = */ +#define KEXECMOD_REC_MAX 255 + uint16_t recs_off; /* Offset to record table from start of page. = */ + /* The record table is an array of = */ + /* struct kexec_module_rec. = */ + uint8_t pg2rec[]; /* One entry per allocatable module page, valu= e */ + /* is record number (starting from 0) associat= ed */ + /* with it. Free pages have value 255. = */ +#define KEXECMOD_PG_FREE 255 +}; + +struct kexec_module_rec { + uint16_t offset; /* Offset to record from start of page. = */ + uint8_t type; /* Type of record. = */ +#define KEXECMOD_REC_NONE 0 + uint8_t size; /* Size of record. = */ +}; + +#ifndef CONFIG_KEXEC_MODULE_PAGES +#define CONFIG_KEXEC_MODULE_PAGES 0 +#endif + +extern unsigned long kexec_mod_start; +extern struct kexec_module *mod_ptr; + /* One element of kexec actions (last element must have action KEXEC_CALL)= : */ struct kexec_action { enum { @@ -60,4 +102,7 @@ int kexec_move_used_pages(unsigned long boundary, unsign= ed long kernel, unsigned long kernel_size); void kexec_move_used_pages_undo(void); =20 +/* Check for kexec module and create kexec memory if needed. */ +void kexec_module(unsigned long start_pfn, unsigned long max_pfn); + #endif /* _KEXEC_H */ diff --git a/include/x86/arch_mm.h b/include/x86/arch_mm.h index a1b975dc..ae56781e 100644 --- a/include/x86/arch_mm.h +++ b/include/x86/arch_mm.h @@ -289,6 +289,7 @@ unsigned long alloc_virt_kernel(unsigned n_pages); =20 void arch_mm_pre_suspend(void); void arch_mm_post_suspend(int canceled); +void set_reserved_range(unsigned long start, unsigned long end); =20 #ifndef CONFIG_PARAVIRT void arch_print_memmap(void); diff --git a/kexec.c b/kexec.c index 2607c819..ded29882 100644 --- a/kexec.c +++ b/kexec.c @@ -250,3 +250,6 @@ int kexec_add_action(int action, void *dest, void *src,= unsigned int len) =20 return 0; } + +unsigned long kexec_mod_start; +struct kexec_module *mod_ptr; diff --git a/mm.c b/mm.c index 8c41d2f2..b5e8d801 100644 --- a/mm.c +++ b/mm.c @@ -44,6 +44,7 @@ #include #include #include +#include =20 /* * ALLOCATION BITMAP @@ -503,6 +504,11 @@ void init_mm(void) arch_init_mm(&start_pfn, &max_pfn); get_max_pages(); =20 +#ifdef CONFIG_KEXEC + /* To be called after arch_init_mm() and before init_page_allocator().= */ + kexec_module(start_pfn, max_pfn); +#endif + /* Now we can initialise the page allocator. */ init_page_allocator(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn)); printk("MM: done\n"); --=20 2.43.0 From nobody Thu Oct 30 23:31:26 2025 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=1751444505; cv=none; d=zohomail.com; s=zohoarc; b=nIdmWMl0UUeYDE84lumtNyQVuOqyKV35lV4QyNlB7QM+L420DiaN719oQ6KRSw7YaT/s+VaT/qsh7LWH8lyLNXjBHNGbsoctWEg868d9jRWSHAKybW+kGQ/hSL8KIuiH9pP4EE/c/XTHiXLj9LU+hwZ8MxSC87J6IiZXDWJIvNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751444505; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NPQ4KdPqGaFvUqDWb/++eBiyJkIUFURqS3mOYAtyiPM=; b=YlgS6WbNopL5LeujYrBx4VMW/6JRCPd1kBhQQ8+0sbI/IwJpvvi47CMGfkE+UbjO8BDmZa8Xe5x4SQy+ezHalAKIKelleYwtS94alOx8bd1tVAoqMN5+hnjhiuvuT/L7U6qlw0Bm5L7IjzNbwiyxTAgRqbFWgfr3wapwW3XPX4Q= 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 175144450553480.47403907842056; Wed, 2 Jul 2025 01:21:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030561.1404304 (Exim 4.92) (envelope-from ) id 1uWsij-0003mu-I3; Wed, 02 Jul 2025 08:21:33 +0000 Received: by outflank-mailman (output) from mailman id 1030561.1404304; Wed, 02 Jul 2025 08:21: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 1uWsij-0003m6-4B; Wed, 02 Jul 2025 08:21:33 +0000 Received: by outflank-mailman (input) for mailman id 1030561; Wed, 02 Jul 2025 08:21: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 1uWsbb-00082X-Vw for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:14:11 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 882321f2-571c-11f0-b894-0df219b8e170; Wed, 02 Jul 2025 10:14:10 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 24EAB1F452; Wed, 2 Jul 2025 08:14:10 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id EF13C13A24; Wed, 2 Jul 2025 08:14:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id K/rrOFHqZGhoSQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:14:09 +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: 882321f2-571c-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444050; 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=NPQ4KdPqGaFvUqDWb/++eBiyJkIUFURqS3mOYAtyiPM=; b=hXncPUa3E1HRPhmofLuq/RAN/uukbVkUMGFk8Gpex8fFSEypkOMdLbhxwQGrMYIqS911de 2HQgufJUD+6cLcHrDeJ6ckBKphxYI8auBN4aFbGSJJTQstRTjnSsGjXW/B/9JsEKuxe5LR igDgaQpAZMV6x2c6QO+xHzPccp0ZNJc= Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=hXncPUa3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444050; 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=NPQ4KdPqGaFvUqDWb/++eBiyJkIUFURqS3mOYAtyiPM=; b=hXncPUa3E1HRPhmofLuq/RAN/uukbVkUMGFk8Gpex8fFSEypkOMdLbhxwQGrMYIqS911de 2HQgufJUD+6cLcHrDeJ6ckBKphxYI8auBN4aFbGSJJTQstRTjnSsGjXW/B/9JsEKuxe5LR igDgaQpAZMV6x2c6QO+xHzPccp0ZNJc= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 13/19] kexec: add support for allocating pages from kexec module memory Date: Wed, 2 Jul 2025 10:12:48 +0200 Message-ID: <20250702081254.14383-14-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.com:dkim,suse.com:mid,suse.com:email]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received,2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[suse.com:+] X-Spam-Level: X-Spam-Flag: NO X-Rspamd-Queue-Id: 24EAB1F452 X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: -3.01 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444507421116600 Content-Type: text/plain; charset="utf-8" Add the needed functions for allocating and freeing memory pages of the kexec module. As the pages are always related to a kexec module record, add the related utility functions, too. For now only support adding records and retrieving them. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- arch/x86/kexec.c | 16 +++++++ include/kexec.h | 52 +++++++++++++++++++++ kexec.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 183 insertions(+) diff --git a/arch/x86/kexec.c b/arch/x86/kexec.c index 7fb98473..8b3e841a 100644 --- a/arch/x86/kexec.c +++ b/arch/x86/kexec.c @@ -238,6 +238,9 @@ static void get_mod_addr(unsigned long from, unsigned l= ong to) #define min(a, b) ((a) < (b) ? (a) : (b)) void kexec_module(unsigned long start_pfn, unsigned long max_pfn) { + unsigned int i; + char *rec_end; + /* Reuse already existing kexec module. */ mod_ptr =3D kexec_check_module(); if ( !mod_ptr && CONFIG_KEXEC_MODULE_PAGES ) @@ -255,11 +258,24 @@ void kexec_module(unsigned long start_pfn, unsigned l= ong max_pfn) sizeof(mod_ptr->eye_catcher)); mod_ptr->n_pages =3D CONFIG_KEXEC_MODULE_PAGES - 1; memset(mod_ptr->pg2rec, KEXECMOD_PG_FREE, mod_ptr->n_pages); + mod_ptr->n_records =3D 16; mod_ptr->recs_off =3D sizeof(struct kexec_module) + CONFIG_KEXEC_MODULE_PAGES + (mod_ptr->n_pages = & 1); =20 set_reserved_range(kexec_mod_start, (unsigned long)mod_ptr + PAGE_= SIZE); } + + mod_recs =3D (void *)((unsigned long)mod_ptr + mod_ptr->recs_off); + mod_rec_start =3D (char *)(mod_recs + mod_ptr->n_records); + mod_rec_end =3D mod_rec_start; + for ( i =3D 0; i < mod_ptr->n_records; i++ ) + { + if ( mod_recs[i].type =3D=3D KEXECMOD_REC_NONE ) + continue; + rec_end =3D (char *)mod_ptr + mod_recs[i].offset + mod_recs[i].siz= e; + if ( mod_rec_end < rec_end ) + mod_rec_end =3D rec_end; + } } =20 void kexec_set_param_loc(const char *cmdline) diff --git a/include/kexec.h b/include/kexec.h index 0200005f..1e753ee1 100644 --- a/include/kexec.h +++ b/include/kexec.h @@ -43,6 +43,9 @@ struct kexec_module_rec { =20 extern unsigned long kexec_mod_start; extern struct kexec_module *mod_ptr; +extern struct kexec_module_rec *mod_recs; +extern char *mod_rec_start; +extern char *mod_rec_end; =20 /* One element of kexec actions (last element must have action KEXEC_CALL)= : */ struct kexec_action { @@ -56,6 +59,17 @@ struct kexec_action { void *src; }; =20 +#ifdef CONFIG_KEXEC +unsigned long kexec_alloc_mod_pages(unsigned int recid, unsigned int n); +void kexec_free_mod_pages(unsigned int recid, unsigned long addr, + unsigned int n); +int kexec_find_mod_record(unsigned int start_idx, unsigned int type, + unsigned int *size); +int kexec_add_mod_record(unsigned int type, void *addr, unsigned int size); +int kexec_upd_mod_record(unsigned int idx, unsigned int type, + void *addr, unsigned int size); +int kexec_read_mod_record(unsigned int idx, void *addr, unsigned int size); + #define KEXEC_MAX_ACTIONS 16 =20 extern char _kexec_start[], _kexec_end[]; @@ -105,4 +119,42 @@ void kexec_move_used_pages_undo(void); /* Check for kexec module and create kexec memory if needed. */ void kexec_module(unsigned long start_pfn, unsigned long max_pfn); =20 +#else /* CONFIG_KEXEC */ +static inline unsigned long kexec_alloc_mod_pages(unsigned int recid, + unsigned int n) +{ + return 0; +} + +static inline void kexec_free_mod_pages(unsigned int recid, unsigned long = addr, + unsigned int n) +{ +} + +static inline int kexec_find_mod_record(unsigned int start_idx, + unsigned int type, unsigned int *s= ize) +{ + return 0; +} + +static inline int kexec_add_mod_record(unsigned int type, void *addr, + unsigned int size) +{ + return 0; +} + +static inline int kexec_upd_mod_record(unsigned int idx, unsigned int type, + void *addr, unsigned int size) +{ + return 0; +} + +static inline int kexec_read_mod_record(unsigned int idx, void *addr, + unsigned int size) +{ + return 0; +} + +#endif + #endif /* _KEXEC_H */ diff --git a/kexec.c b/kexec.c index ded29882..f17ed13d 100644 --- a/kexec.c +++ b/kexec.c @@ -253,3 +253,118 @@ int kexec_add_action(int action, void *dest, void *sr= c, unsigned int len) =20 unsigned long kexec_mod_start; struct kexec_module *mod_ptr; +struct kexec_module_rec *mod_recs; +char *mod_rec_start; +char *mod_rec_end; + +unsigned long kexec_alloc_mod_pages(unsigned int recid, unsigned int n) +{ + unsigned int first =3D 0, i; + + for ( i =3D 0; i < mod_ptr->n_pages; i++ ) + { + if ( i - first =3D=3D n - 1 ) + { + for ( i =3D 0; i < n; i++ ) + mod_ptr->pg2rec[first + i] =3D recid; + + return kexec_mod_start + PFN_PHYS(first); + } + + if ( mod_ptr->pg2rec[i] !=3D KEXECMOD_PG_FREE ) + first =3D i + 1; + } + + printk("Kexec module out of memory\n"); + BUG(); +} + +void kexec_free_mod_pages(unsigned int recid, unsigned long addr, + unsigned int n) +{ + unsigned int s =3D PHYS_PFN(addr - kexec_mod_start); + unsigned int i; + + BUG_ON(addr < kexec_mod_start || + addr + PFN_PHYS(n) > (unsigned long)mod_ptr); + + for ( i =3D 0; i < n; i++ ) + { + BUG_ON(mod_ptr->pg2rec[s + i] !=3D recid); + mod_ptr->pg2rec[s + i] =3D KEXECMOD_PG_FREE; + } +} + +int kexec_find_mod_record(unsigned int start_idx, unsigned int type, + unsigned int *size) +{ + unsigned int i; + + for ( i =3D start_idx; i < mod_ptr->n_records; i++ ) + { + if ( mod_recs[i].type =3D=3D type ) + { + *size =3D mod_recs[i].size; + return i; + } + } + + return -ENOENT; +} + +int kexec_add_mod_record(unsigned int type, void *addr, unsigned int size) +{ + unsigned int i; + + if ( mod_rec_end + size > (char *)mod_ptr + PAGE_SIZE ) + { + /* TODO: support compressing record space. */ + printk("Kexec module record space exhausted\n"); + BUG(); + } + + for ( i =3D 0; i < mod_ptr->n_records; i++ ) + { + if ( mod_recs[i].type =3D=3D KEXECMOD_REC_NONE ) + { + mod_recs[i].offset =3D mod_rec_end - (char *)mod_ptr; + mod_recs[i].type =3D type; + mod_recs[i].size =3D size; + memcpy(mod_rec_end, addr, size); + mod_rec_end =3D mod_rec_end + size; + + return i; + } + } + + /* TODO: support extending the mod_recs[] table. */ + printk("Kexec module record table exhausted\n"); + BUG(); +} + +int kexec_upd_mod_record(unsigned int idx, unsigned int type, + void *addr, unsigned int size) +{ + if ( idx >=3D mod_ptr->n_records ) + return -ENOENT; + + if ( mod_recs[idx].type !=3D type || mod_recs[idx].size !=3D size ) + return -EINVAL; + + memcpy((char *)mod_ptr + mod_recs[idx].offset, addr, size); + + return 0; +} + +int kexec_read_mod_record(unsigned int idx, void *addr, unsigned int size) +{ + if ( idx >=3D mod_ptr->n_records ) + return -ENOENT; + + if ( mod_recs[idx].size !=3D size ) + return -EINVAL; + + memcpy(addr, (char *)mod_ptr + mod_recs[idx].offset, size); + + return 0; +} --=20 2.43.0 From nobody Thu Oct 30 23:31:26 2025 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=1751444464; cv=none; d=zohomail.com; s=zohoarc; b=HFbBXjMv0fTm3atttWbz8HijKpeOKEAWTyB0AMafNKMgzCLIX7t5uKv9jY4Z3Ga9MYiz8UUkpWsPhMShjD4n62BIo5ctm4n5me2BtSaSi9mAhuP7rWN91d7cVegYVqspbFfbixwmntkn36v+26+7gCBVXCDr/QBHdWpVME9m6I4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751444464; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AClNjBUa8IKDahSUwbZj7GWAX64ZZsn1WmMAweYfVPU=; b=Z3nIAwm4i0SXluP32i9TdQ+XJJJA1QLnXJm74D676/ZJ/SZAfQnNLQFTVhLi96ivgW8RA4FGFMRH0NT3WICCMdLqEKemxwmC9oH3B+CNB0yMAezVZ5vUpTRHKas+W72S1PHHuMW5DmPTZJ9APnm5B/OkW2G7K83B8mW+G4HPmkc= 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 1751444464518817.7530444807869; Wed, 2 Jul 2025 01:21:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030445.1404161 (Exim 4.92) (envelope-from ) id 1uWsi2-0005fu-PZ; Wed, 02 Jul 2025 08:20:50 +0000 Received: by outflank-mailman (output) from mailman id 1030445.1404161; Wed, 02 Jul 2025 08:20:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWsi2-0005ez-Cu; Wed, 02 Jul 2025 08:20:50 +0000 Received: by outflank-mailman (input) for mailman id 1030445; Wed, 02 Jul 2025 08:20:49 +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 1uWsbg-00082Y-Gy for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:14:16 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8b71dc39-571c-11f0-a313-13f23c93f187; Wed, 02 Jul 2025 10:14:16 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B39E61F454; Wed, 2 Jul 2025 08:14:15 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8A7AD13A24; Wed, 2 Jul 2025 08:14:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id pKZMIFfqZGhsSQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:14:15 +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: 8b71dc39-571c-11f0-a313-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444055; 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=AClNjBUa8IKDahSUwbZj7GWAX64ZZsn1WmMAweYfVPU=; b=WbXtKzGHGA0ajhZ8IOQHOWZWrliegkzhZIi4aU0iHuZkDLvsdla5zr9l5DwwWxZ82clPJ1 pSIRaKP+KAYUVZLXx9k57w7vDRGqxJLNPCnr23Rj3pDXI/xiJgTCyWYVWryLrvi5Orz17r GcN150F9qeLiwB0oyUyoa5RzK3nr6xo= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444055; 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=AClNjBUa8IKDahSUwbZj7GWAX64ZZsn1WmMAweYfVPU=; b=WbXtKzGHGA0ajhZ8IOQHOWZWrliegkzhZIi4aU0iHuZkDLvsdla5zr9l5DwwWxZ82clPJ1 pSIRaKP+KAYUVZLXx9k57w7vDRGqxJLNPCnr23Rj3pDXI/xiJgTCyWYVWryLrvi5Orz17r GcN150F9qeLiwB0oyUyoa5RzK3nr6xo= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 14/19] 9pfs: store bepath in struct struct dev_9pfs Date: Wed, 2 Jul 2025 10:12:49 +0200 Message-ID: <20250702081254.14383-15-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Flag: NO X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.com:mid,suse.com:email]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444466997116600 Content-Type: text/plain; charset="utf-8" Use struct dev_9pfs for storing the backend path of the device state in order to avoid code duplication in init_9pfront() and shutdown_9pfront(). Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- 9pfront.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/9pfront.c b/9pfront.c index 895426d1..2bfc49b1 100644 --- a/9pfront.c +++ b/9pfront.c @@ -25,6 +25,7 @@ struct dev_9pfs { char nodename[20]; unsigned int dom; char *backend; + char bepath[64]; =20 char *tag; const char *mnt; @@ -1103,7 +1104,6 @@ void *init_9pfront(unsigned int id, const char *mnt) char *reason =3D ""; xenbus_transaction_t xbt; int retry =3D 1; - char bepath[64] =3D { 0 }; XenbusState state; unsigned int i; void *addr; @@ -1137,11 +1137,12 @@ void *init_9pfront(unsigned int id, const char *mnt) if ( msg ) goto err; =20 - snprintf(bepath, sizeof(bepath), "%s/state", dev->backend); - free(xenbus_watch_path_token(XBT_NIL, bepath, bepath, &dev->events)); - state =3D xenbus_read_integer(bepath); + snprintf(dev->bepath, sizeof(dev->bepath), "%s/state", dev->backend); + free(xenbus_watch_path_token(XBT_NIL, dev->bepath, dev->bepath, + &dev->events)); + state =3D xenbus_read_integer(dev->bepath); while ( msg =3D=3D NULL && state < XenbusStateInitWait ) - msg =3D xenbus_wait_for_state_change(bepath, &state, &dev->events); + msg =3D xenbus_wait_for_state_change(dev->bepath, &state, &dev->ev= ents); if ( msg || state !=3D XenbusStateInitWait ) { reason =3D "illegal backend state"; @@ -1228,9 +1229,9 @@ void *init_9pfront(unsigned int id, const char *mnt) free(xenbus_transaction_end(xbt, 0, &retry)); } =20 - state =3D xenbus_read_integer(bepath); + state =3D xenbus_read_integer(dev->bepath); while ( msg =3D=3D NULL && state < XenbusStateConnected ) - msg =3D xenbus_wait_for_state_change(bepath, &state, &dev->events); + msg =3D xenbus_wait_for_state_change(dev->bepath, &state, &dev->ev= ents); if ( msg || state !=3D XenbusStateConnected ) { reason =3D "illegal backend state"; @@ -1263,8 +1264,6 @@ void *init_9pfront(unsigned int id, const char *mnt) free(xenbus_transaction_end(xbt, 1, &retry)); =20 err: - if ( bepath[0] ) - free(xenbus_unwatch_path_token(XBT_NIL, bepath, bepath)); if ( msg ) printk("9pfsfront add %u failed, error %s accessing Xenstore\n", id, msg); @@ -1279,22 +1278,20 @@ EXPORT_SYMBOL(init_9pfront); void shutdown_9pfront(void *dev) { struct dev_9pfs *dev9p =3D dev; - char bepath[64]; XenbusState state; char *msg; char *reason =3D ""; =20 umount(dev9p->mnt); - snprintf(bepath, sizeof(bepath), "%s/state", dev9p->backend); =20 msg =3D xenbus_printf(XBT_NIL, dev9p->nodename, "state", "%u", XenbusStateClosing); if ( msg ) goto err; =20 - state =3D xenbus_read_integer(bepath); + state =3D xenbus_read_integer(dev9p->bepath); while ( msg =3D=3D NULL && state < XenbusStateClosing) - msg =3D xenbus_wait_for_state_change(bepath, &state, &dev9p->event= s); + msg =3D xenbus_wait_for_state_change(dev9p->bepath, &state, &dev9p= ->events); if ( msg || state !=3D XenbusStateClosing ) { reason =3D "illegal backend state"; --=20 2.43.0 From nobody Thu Oct 30 23:31:26 2025 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=1751444471; cv=none; d=zohomail.com; s=zohoarc; b=OtRksRHz8sZIJSpAkz/sbcHbPRlqQ1wGRoiOmxRmJCbYfcv1WZsbWdn13KZUgmdNKLOFLz3pvgPKYrF9MTeNJhum19FyWibWwI1OMTgbGUNRR9YAqZLuxPoq9GWOvgyJk6s5jIn6crvLNIJCSyQUY+5cr8YSNlLZjikvN6LlK+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751444471; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ubR6pSt9182ihX0qStfZwbGBhcxTfFCMnfWKOJagOwc=; b=HCzWptFM07ljdlt/DUjiDHPL7Dna9TIzvHksdbuzH+sMwNAMF6HdpXeCS5AsKSaJWwVvGzwgkmw0RK4rbRakWQ3JQHP+iin2pddxanruzcQV2ZydaIfkTrHfJnJdpLKUpWkiVql4i9Q9sD84SpcIphu1BRqU0DdvbyqjaH4uyKw= 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 1751444471680596.602844489244; Wed, 2 Jul 2025 01:21:11 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030462.1404201 (Exim 4.92) (envelope-from ) id 1uWsi8-00070H-Fg; Wed, 02 Jul 2025 08:20:56 +0000 Received: by outflank-mailman (output) from mailman id 1030462.1404201; Wed, 02 Jul 2025 08:20:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWsi8-0006zZ-7c; Wed, 02 Jul 2025 08:20:56 +0000 Received: by outflank-mailman (input) for mailman id 1030462; Wed, 02 Jul 2025 08:20:55 +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 1uWsbm-00082Y-7G for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:14:22 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8ecf6b26-571c-11f0-a313-13f23c93f187; Wed, 02 Jul 2025 10:14:21 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 507E91F445; Wed, 2 Jul 2025 08:14:21 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2425413A24; Wed, 2 Jul 2025 08:14:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id og1IB13qZGhxSQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:14: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: 8ecf6b26-571c-11f0-a313-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444061; 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=ubR6pSt9182ihX0qStfZwbGBhcxTfFCMnfWKOJagOwc=; b=gXY91VIAg53p7prR25YIH3AJCIjf7Q9ImmgpAbo6e3BXm1x2tPRztRcv2BuDLdWWvaD8r3 vRhKqtTMQCBvpGSYjadSVC1iHhovqQGBjjwd5U0QhdQpeFijJSUvyh+qY7l/fc04kT9/qW M5nUHGuy+FiJDG294Ydy2b9egOdbDoc= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444061; 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=ubR6pSt9182ihX0qStfZwbGBhcxTfFCMnfWKOJagOwc=; b=gXY91VIAg53p7prR25YIH3AJCIjf7Q9ImmgpAbo6e3BXm1x2tPRztRcv2BuDLdWWvaD8r3 vRhKqtTMQCBvpGSYjadSVC1iHhovqQGBjjwd5U0QhdQpeFijJSUvyh+qY7l/fc04kT9/qW M5nUHGuy+FiJDG294Ydy2b9egOdbDoc= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 15/19] 9pfs: refactor init_9pfront() Date: Wed, 2 Jul 2025 10:12:50 +0200 Message-ID: <20250702081254.14383-16-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Flag: NO X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444472739116600 Content-Type: text/plain; charset="utf-8" Move the Xenstore and backend interface related handling into a sub-function in order to prepare supporting reconnecting to an active 9pfs device after kexec. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- 9pfront.c | 136 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 86 insertions(+), 50 deletions(-) diff --git a/9pfront.c b/9pfront.c index 2bfc49b1..8da2f726 100644 --- a/9pfront.c +++ b/9pfront.c @@ -1097,68 +1097,65 @@ static void free_9pfront(struct dev_9pfs *dev) free(dev); } =20 -void *init_9pfront(unsigned int id, const char *mnt) +static bool issue_err(struct dev_9pfs *dev, char *msg, char *reason) +{ + if ( msg ) + { + printk("9pfsfront add %u failed, error %s accessing Xenstore\n", + dev->id, msg); + free(msg); + } + else + printk("9pfsfront add %u failed, %s\n", dev->id, reason); + + return false; +} + +static bool read_config_xs(struct dev_9pfs *dev) { - struct dev_9pfs *dev; char *msg; char *reason =3D ""; - xenbus_transaction_t xbt; - int retry =3D 1; XenbusState state; - unsigned int i; - void *addr; + xenbus_transaction_t xbt; char *version; char *v; - - printk("9pfsfront add %u, for mount at %s\n", id, mnt); - dev =3D malloc(sizeof(*dev)); - memset(dev, 0, sizeof(*dev)); - snprintf(dev->nodename, sizeof(dev->nodename), "device/9pfs/%u", id); - dev->id =3D id; - init_waitqueue_head(&dev->waitq); - init_SEMAPHORE(&dev->ring_out_sem, 1); - init_SEMAPHORE(&dev->ring_in_sem, 1); - dev->fid_mask =3D ~0ULL; - - for ( i =3D 0; i < N_REQS; i++ ) - { - dev->req[i].id =3D i; - dev->req[i].next_free =3D i + 1; - } - dev->free_reqs =3D 0; + void *addr; + unsigned int i; + int retry =3D 1; =20 msg =3D xenbus_read_unsigned(XBT_NIL, dev->nodename, "backend-id", &de= v->dom); if ( msg ) - goto err; + return issue_err(dev, msg, reason); msg =3D xenbus_read_string(XBT_NIL, dev->nodename, "backend", &dev->ba= ckend); if ( msg ) - goto err; + return issue_err(dev, msg, reason); msg =3D xenbus_read_string(XBT_NIL, dev->nodename, "tag", &dev->tag); if ( msg ) - goto err; + return issue_err(dev, msg, reason); =20 snprintf(dev->bepath, sizeof(dev->bepath), "%s/state", dev->backend); free(xenbus_watch_path_token(XBT_NIL, dev->bepath, dev->bepath, &dev->events)); + state =3D xenbus_read_integer(dev->bepath); while ( msg =3D=3D NULL && state < XenbusStateInitWait ) msg =3D xenbus_wait_for_state_change(dev->bepath, &state, &dev->ev= ents); if ( msg || state !=3D XenbusStateInitWait ) { reason =3D "illegal backend state"; - goto err; + return issue_err(dev, msg, reason); } =20 msg =3D xenbus_read_unsigned(XBT_NIL, dev->backend, "max-ring-page-ord= er", &dev->ring_order); if ( msg ) - goto err; + return issue_err(dev, msg, reason); if ( dev->ring_order > DEFAULT_9PFS_RING_ORDER ) dev->ring_order =3D DEFAULT_9PFS_RING_ORDER; =20 msg =3D xenbus_read_string(XBT_NIL, dev->backend, "versions", &version= ); if ( msg ) - goto err; + return issue_err(dev, msg, reason); for ( v =3D version; *v; v++ ) { if ( strtoul(v, &v, 10) =3D=3D 1 && (*v =3D=3D ',' || *v =3D=3D 0)= ) @@ -1170,25 +1167,36 @@ void *init_9pfront(unsigned int id, const char *mnt) { reason =3D "backend published illegal version string"; free(version); - goto err; + return issue_err(dev, msg, reason); } } free(version); if ( v ) { reason =3D "backend doesn't support version 1"; - goto err; + return issue_err(dev, msg, reason); } =20 - dev->ring_ref =3D gnttab_alloc_and_grant((void **)&dev->intf); + dev->intf =3D (void *)alloc_page(); + if ( !dev->intf ) + { + reason =3D "couldn't allocate shared interface page"; + return issue_err(dev, msg, reason); + } memset(dev->intf, 0, PAGE_SIZE); + dev->ring_ref =3D gnttab_grant_access(dev->dom, virt_to_mfn(dev->intf)= , 0); if ( evtchn_alloc_unbound(dev->dom, intr_9pfs, dev, &dev->evtchn) ) { reason =3D "no event channel"; - goto err; + return issue_err(dev, msg, reason); } dev->intf->ring_order =3D dev->ring_order; dev->data.in =3D (void *)alloc_pages(dev->ring_order); + if ( !dev->data.in ) + { + reason =3D "couldn't allocate ring pages"; + return issue_err(dev, msg, reason); + } dev->data.out =3D dev->data.in + XEN_FLEX_RING_SIZE(dev->ring_order); for ( i =3D 0; i < (1 << dev->ring_order); i++ ) { @@ -1204,30 +1212,35 @@ void *init_9pfront(unsigned int id, const char *mnt) free(msg); msg =3D NULL; reason =3D "starting transaction"; - goto err; + return issue_err(dev, msg, reason); } =20 msg =3D xenbus_printf(xbt, dev->nodename, "version", "%u", 1); if ( msg ) - goto err_tr; + break; msg =3D xenbus_printf(xbt, dev->nodename, "num-rings", "%u", 1); if ( msg ) - goto err_tr; + break; msg =3D xenbus_printf(xbt, dev->nodename, "ring-ref0", "%u", dev->ring_ref); if ( msg ) - goto err_tr; + break; msg =3D xenbus_printf(xbt, dev->nodename, "event-channel-0", "%u", dev->evtchn); if ( msg ) - goto err_tr; + break; msg =3D xenbus_printf(xbt, dev->nodename, "state", "%u", XenbusStateInitialised); if ( msg ) - goto err_tr; + break; =20 free(xenbus_transaction_end(xbt, 0, &retry)); } + if ( msg ) + { + free(xenbus_transaction_end(xbt, 1, &retry)); + return issue_err(dev, msg, reason); + } =20 state =3D xenbus_read_integer(dev->bepath); while ( msg =3D=3D NULL && state < XenbusStateConnected ) @@ -1235,13 +1248,42 @@ void *init_9pfront(unsigned int id, const char *mnt) if ( msg || state !=3D XenbusStateConnected ) { reason =3D "illegal backend state"; - goto err; + return issue_err(dev, msg, reason); } =20 msg =3D xenbus_printf(XBT_NIL, dev->nodename, "state", "%u", XenbusStateConnected); if ( msg ) - goto err; + return issue_err(dev, msg, reason); + + return true; +} + +void *init_9pfront(unsigned int id, const char *mnt) +{ + struct dev_9pfs *dev; + char *reason =3D ""; + unsigned int i; + + printk("9pfsfront add %u, for mount at %s\n", id, mnt); + dev =3D malloc(sizeof(*dev)); + memset(dev, 0, sizeof(*dev)); + snprintf(dev->nodename, sizeof(dev->nodename), "device/9pfs/%u", id); + dev->id =3D id; + init_waitqueue_head(&dev->waitq); + init_SEMAPHORE(&dev->ring_out_sem, 1); + init_SEMAPHORE(&dev->ring_in_sem, 1); + dev->fid_mask =3D ~0ULL; + + for ( i =3D 0; i < N_REQS; i++ ) + { + dev->req[i].id =3D i; + dev->req[i].next_free =3D i + 1; + } + dev->free_reqs =3D 0; + + if ( !read_config_xs(dev) ) + goto err_out; =20 unmask_evtchn(dev->evtchn); =20 @@ -1260,17 +1302,11 @@ void *init_9pfront(unsigned int id, const char *mnt) =20 return dev; =20 - err_tr: - free(xenbus_transaction_end(xbt, 1, &retry)); - err: - if ( msg ) - printk("9pfsfront add %u failed, error %s accessing Xenstore\n", - id, msg); - else - printk("9pfsfront add %u failed, %s\n", id, reason); + printk("9pfsfront add %u failed, %s\n", id, reason); + + err_out: free_9pfront(dev); - free(msg); return NULL; } EXPORT_SYMBOL(init_9pfront); --=20 2.43.0 From nobody Thu Oct 30 23:31:26 2025 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=1751444467; cv=none; d=zohomail.com; s=zohoarc; b=TE189M0jNEU3B3XUKHIm1EuENim2Xa9zLNNlXc/RqjNwp06wU7ZrjJPgom1RDW+hYGvApvbLuO0b6Yb/Qmq7StmSCFX0OWpUqHPEO5b2+ghrZFQgwyfqS+x6S2U4QU/JPHZsYCuiob8BIQ+Lppd7/ikGf3Nfhvgam0bmz1VUWmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751444467; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zDtKgh+ZY1/kdJFUAdITx2mhsJQDxIfukWhnUYKt9Xs=; b=O/E2z6Az5ZO6hVlryJNRbgiSMKIj8QYvkh9WISW/j1YxlRv0axAeubTm5NZZg7P0XnMm24f+aiio4G1+kJzk6NpA3KSwJDfoXw9bU5u0AEsHiGiOQo5WK/WIaA0pw1hrMeHD3rQ+utJdf8HgTQo1AkyrGoA29d4WTMsv0k8gnz4= 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 1751444467793270.6287716984958; Wed, 2 Jul 2025 01:21:07 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030444.1404159 (Exim 4.92) (envelope-from ) id 1uWsi2-0005cv-DP; Wed, 02 Jul 2025 08:20:50 +0000 Received: by outflank-mailman (output) from mailman id 1030444.1404159; Wed, 02 Jul 2025 08:20:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWsi2-0005cN-3N; Wed, 02 Jul 2025 08:20:50 +0000 Received: by outflank-mailman (input) for mailman id 1030444; Wed, 02 Jul 2025 08:20:49 +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 1uWsbt-00082X-ID for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:14:29 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 921f644a-571c-11f0-b894-0df219b8e170; Wed, 02 Jul 2025 10:14:27 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DA91E1F445; Wed, 2 Jul 2025 08:14:26 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B1AB813A24; Wed, 2 Jul 2025 08:14:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id OcHtKWLqZGh5SQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:14:26 +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: 921f644a-571c-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444066; 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=zDtKgh+ZY1/kdJFUAdITx2mhsJQDxIfukWhnUYKt9Xs=; b=E9DWZ6Na0viwWiCWPwEvvGIAMRSQpkp9uWBmswocEggnZaHHU0DJICmY4fc/xo8wyVo5hS aeybllRqaGHgyXQRMEha9KuwX4F58BjCjSQkbp95iW+A4l7huTXTxERt5Yomy5FEITz5J8 SNJPtsk+IwWk2YMdLIt2z9f380jlCPQ= Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=E9DWZ6Na DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444066; 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=zDtKgh+ZY1/kdJFUAdITx2mhsJQDxIfukWhnUYKt9Xs=; b=E9DWZ6Na0viwWiCWPwEvvGIAMRSQpkp9uWBmswocEggnZaHHU0DJICmY4fc/xo8wyVo5hS aeybllRqaGHgyXQRMEha9KuwX4F58BjCjSQkbp95iW+A4l7huTXTxERt5Yomy5FEITz5J8 SNJPtsk+IwWk2YMdLIt2z9f380jlCPQ= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 16/19] gnttab: remove gnttab_alloc_and_grant() function Date: Wed, 2 Jul 2025 10:12:51 +0200 Message-ID: <20250702081254.14383-17-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:dkim,suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from,2a07:de40:b281:106:10:150:64:167:received]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[suse.com:+] X-Spam-Level: X-Spam-Flag: NO X-Rspamd-Queue-Id: DA91E1F445 X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: -3.01 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444468721116600 Content-Type: text/plain; charset="utf-8" The last user of gnttab_alloc_and_grant() is gone. Remove gnttab_alloc_and_grant() as it is doing more harm than good. It is hard coded to only grant access for dom0, which is not really clear from looking at the function name. It would be possible to add a domid parameter, but given its now 0 users, there doesn't seem to be a real demand for that function. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- gnttab.c | 13 ------------- include/gnttab.h | 1 - 2 files changed, 14 deletions(-) diff --git a/gnttab.c b/gnttab.c index 5b04ab01..6bac0905 100644 --- a/gnttab.c +++ b/gnttab.c @@ -149,19 +149,6 @@ gnttab_end_transfer(grant_ref_t ref) } EXPORT_SYMBOL(gnttab_end_transfer); =20 -grant_ref_t -gnttab_alloc_and_grant(void **map) -{ - unsigned long mfn; - grant_ref_t gref; - - *map =3D (void *)alloc_page(); - mfn =3D virt_to_mfn(*map); - gref =3D gnttab_grant_access(0, mfn, 0); - return gref; -} -EXPORT_SYMBOL(gnttab_alloc_and_grant); - static const char * const gnttabop_error_msgs[] =3D GNTTABOP_error_msgs; =20 const char * diff --git a/include/gnttab.h b/include/gnttab.h index 974cb89d..108c4425 100644 --- a/include/gnttab.h +++ b/include/gnttab.h @@ -4,7 +4,6 @@ #include =20 void init_gnttab(void); -grant_ref_t gnttab_alloc_and_grant(void **map); grant_ref_t gnttab_grant_access(domid_t domid, unsigned long frame, int readonly); grant_ref_t gnttab_grant_transfer(domid_t domid, unsigned long pfn); --=20 2.43.0 From nobody Thu Oct 30 23:31:26 2025 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=1751444458; cv=none; d=zohomail.com; s=zohoarc; b=jirDqO2fcx3b0D4fcIVkVR6Op9D2cUpSJYACBpGwarLierJ2xMqdgwlp8i3SynziX+tiFOd5ulNFiZVwMHmXDacTbzjYFRUpbEJRAeWa1aHbZUnwZgxgxIGZtDOU3Lp7fnPrwNzCmFOWl5vNT8i7kSOgNCL7kmbSoNvJT+elF+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751444458; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=54mI4K8Jcav8/UHRZBznVBm2r964lgKK2S2ajy90lfI=; b=MDGYJY7NSDDcQ2TqrYts9QvjcgeA7cRZydb7n5KsDfCagEm8/smb8B4VFrgd+z6qzztevPv0epCT2cV7B+PBq3Sn+u2w0rLLBr1douSC6CNLT870sT4n0mNQ8aoFqE5UxJHP68AGdFEZQrifyWrYtQUohG28Ffa4bZt7Yn7M6ns= 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 1751444458751127.51004093491667; Wed, 2 Jul 2025 01:20:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030430.1404088 (Exim 4.92) (envelope-from ) id 1uWshs-00042p-1V; Wed, 02 Jul 2025 08:20:40 +0000 Received: by outflank-mailman (output) from mailman id 1030430.1404088; Wed, 02 Jul 2025 08:20: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 1uWshr-00042i-Tx; Wed, 02 Jul 2025 08:20:39 +0000 Received: by outflank-mailman (input) for mailman id 1030430; Wed, 02 Jul 2025 08:20: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 1uWsby-00082X-Ot for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:14:34 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 9574905e-571c-11f0-b894-0df219b8e170; Wed, 02 Jul 2025 10:14:33 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7ED902117F; Wed, 2 Jul 2025 08:14:32 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 5243213A24; Wed, 2 Jul 2025 08:14:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id CtF3EmjqZGh/SQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:14:32 +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: 9574905e-571c-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444072; 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=54mI4K8Jcav8/UHRZBznVBm2r964lgKK2S2ajy90lfI=; b=fQ91/Tq1HHqJAZXlitD6NTxWGKPPuAPEEk9yW0rDf+nuEHweE0EAuAGuC2V8HRZf5WAWV5 M/xczjTIe2iIXLlinC61i/f0wPUGimKtMh1+pL9vglLC81m712y4AJmAA2HDolJufqlyuL MYs/6LkebIWR+huYNvzaP6iVw1m+yJM= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b="fQ91/Tq1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444072; 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=54mI4K8Jcav8/UHRZBznVBm2r964lgKK2S2ajy90lfI=; b=fQ91/Tq1HHqJAZXlitD6NTxWGKPPuAPEEk9yW0rDf+nuEHweE0EAuAGuC2V8HRZf5WAWV5 M/xczjTIe2iIXLlinC61i/f0wPUGimKtMh1+pL9vglLC81m712y4AJmAA2HDolJufqlyuL MYs/6LkebIWR+huYNvzaP6iVw1m+yJM= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 17/19] gnttab: add function to obtain memory address from grantref Date: Wed, 2 Jul 2025 10:12:52 +0200 Message-ID: <20250702081254.14383-18-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:dkim,suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from,2a07:de40:b281:106:10:150:64:167:received]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[suse.com:+] X-Spam-Level: X-Spam-Flag: NO X-Rspamd-Queue-Id: 7ED902117F X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: -3.01 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444460734116600 Content-Type: text/plain; charset="utf-8" Add a new function gnttab_get_addr() to obtain a memory pointer for a given grant reference. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- gnttab.c | 10 ++++++++++ include/gnttab.h | 1 + 2 files changed, 11 insertions(+) diff --git a/gnttab.c b/gnttab.c index 6bac0905..52d6792a 100644 --- a/gnttab.c +++ b/gnttab.c @@ -149,6 +149,16 @@ gnttab_end_transfer(grant_ref_t ref) } EXPORT_SYMBOL(gnttab_end_transfer); =20 +void *gnttab_get_addr(grant_ref_t ref) +{ + BUG_ON(ref >=3D NR_GRANT_ENTRIES || ref < NR_RESERVED_ENTRIES); + + if ( !gnttab_table[ref].flags ) + return NULL; + + return mfn_to_virt(gnttab_table[ref].frame); +} + static const char * const gnttabop_error_msgs[] =3D GNTTABOP_error_msgs; =20 const char * diff --git a/include/gnttab.h b/include/gnttab.h index 108c4425..46e72a36 100644 --- a/include/gnttab.h +++ b/include/gnttab.h @@ -9,6 +9,7 @@ grant_ref_t gnttab_grant_access(domid_t domid, unsigned lon= g frame, grant_ref_t gnttab_grant_transfer(domid_t domid, unsigned long pfn); unsigned long gnttab_end_transfer(grant_ref_t gref); int gnttab_end_access(grant_ref_t ref); +void *gnttab_get_addr(grant_ref_t ref); const char *gnttabop_error(int16_t status); void fini_gnttab(void); void suspend_gnttab(void); --=20 2.43.0 From nobody Thu Oct 30 23:31:26 2025 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=1751444508; cv=none; d=zohomail.com; s=zohoarc; b=ERD2WQWo4mjqo53eRM/lN7M6kN0N/LOylLErysorJJd/zOo4idudqKK7lxABxF6JNAst26SsVZN6giaQWdDA3i7Lmk6obuPXPN8soqMW7lusv+nnmrQ28dTifHqlAuAH0YTFQyvJ/nYKqoNncAueosMWVjOA4d/3qLVTOoFE5qU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751444508; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IOlYonHclfoRpw7enkWmqDj5I9EaGv63Xf2WTPy7orA=; b=If31Tsu+O8jEolU06vteZV3CPybDdDVkr5/jgNZ0FotnmOTpGsunZIegKt1R54zmFuCL5EZUCmh2vQOfdGvaQhREftj28J4mVT2sXZ00jzeDF7bDS02YGw72K3Cs418WvxhOgez8wwu6qJ4Eisn7zJMRaI/nIbxGTS8tEXPP7Vo= 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 1751444508942403.43723498676184; Wed, 2 Jul 2025 01:21:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030568.1404325 (Exim 4.92) (envelope-from ) id 1uWsil-0004T1-On; Wed, 02 Jul 2025 08:21:35 +0000 Received: by outflank-mailman (output) from mailman id 1030568.1404325; Wed, 02 Jul 2025 08:21:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWsil-0004Rf-L6; Wed, 02 Jul 2025 08:21:35 +0000 Received: by outflank-mailman (input) for mailman id 1030568; Wed, 02 Jul 2025 08:21:33 +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 1uWsc3-00082Y-2D for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:14:39 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 98d33730-571c-11f0-a313-13f23c93f187; Wed, 02 Jul 2025 10:14:38 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 11E3221175; Wed, 2 Jul 2025 08:14:38 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id DD31A13A24; Wed, 2 Jul 2025 08:14:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id A0ptNG3qZGiQSQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:14:37 +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: 98d33730-571c-11f0-a313-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444078; 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=IOlYonHclfoRpw7enkWmqDj5I9EaGv63Xf2WTPy7orA=; b=f+GFtsUZ7F//peCVEaNHQTq0QAx9UWtfSwAvQ7VXwDUSdDItK1h9buqwSdRzcXMx0yqVjO CR3tl8hrURsfptqpNeroPzz6BNLg1Vitpfl+AucQ0o2YI2T/sPBiiOhuKMqEFRdtzD4xjt sNtha5Pd0MjsUms8oWTEZTr7WgR7Qi4= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444078; 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=IOlYonHclfoRpw7enkWmqDj5I9EaGv63Xf2WTPy7orA=; b=f+GFtsUZ7F//peCVEaNHQTq0QAx9UWtfSwAvQ7VXwDUSdDItK1h9buqwSdRzcXMx0yqVjO CR3tl8hrURsfptqpNeroPzz6BNLg1Vitpfl+AucQ0o2YI2T/sPBiiOhuKMqEFRdtzD4xjt sNtha5Pd0MjsUms8oWTEZTr7WgR7Qi4= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 18/19] 9pfs: add support to keep device opened across kexec Date: Wed, 2 Jul 2025 10:12:53 +0200 Message-ID: <20250702081254.14383-19-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.com:email,suse.com:mid]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: -2.80 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444509591116600 Content-Type: text/plain; charset="utf-8" In order to support Xenstore-stubdom live update, the 9pfs device used to save and restore the Xenstore state needs to be kept open across kexec, as otherwise re-opening of the device using the new kernel would not work (this would require Xenstore to be active, which is obviously not possible before having read the saved state). Add an alternative init function for a 9pfs device supporting to take the configuration from the kexec module instead of Xenstore. Add support for creating the device using the kexec module, too. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- 9pfront.c | 120 +++++++++++++++++++++++++++++++++++++++++----- include/9pfront.h | 9 ++++ include/kexec.h | 1 + 3 files changed, 117 insertions(+), 13 deletions(-) diff --git a/9pfront.c b/9pfront.c index 8da2f726..b3106d13 100644 --- a/9pfront.c +++ b/9pfront.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,7 @@ struct dev_9pfs { unsigned int dom; char *backend; char bepath[64]; + bool kexecmem; =20 char *tag; const char *mnt; @@ -58,6 +60,13 @@ struct dev_9pfs { unsigned long long fid_mask; /* Bit mask for free fids. */ }; =20 +struct kexec_9pfs_rec { + grant_ref_t ring_ref; + evtchn_port_t evtchn; + RING_IDX prod_pvt_out; + RING_IDX cons_pvt_in; +}; + struct file_9pfs { uint32_t fid; struct dev_9pfs *dev; @@ -898,7 +907,7 @@ static bool path_canonical(const char *pathname) return true; } =20 -static int connect_9pfs(struct dev_9pfs *dev) +static int connect_9pfs(struct dev_9pfs *dev, bool do_attach) { int ret; =20 @@ -906,7 +915,7 @@ static int connect_9pfs(struct dev_9pfs *dev) if ( ret ) return ret; =20 - return p9_attach(dev); + return do_attach ? p9_attach(dev) : 0; } =20 static void intr_9pfs(evtchn_port_t port, struct pt_regs *regs, void *data) @@ -1079,6 +1088,9 @@ static int open_9pfs(struct mount_point *mnt, const c= har *pathname, int flags, return -1; } =20 +static int kexec_recid =3D -1; +static struct dev_9pfs *kexec_dev; + static void free_9pfront(struct dev_9pfs *dev) { unsigned int i; @@ -1087,13 +1099,22 @@ static void free_9pfront(struct dev_9pfs *dev) { for ( i =3D 0; i < (1 << dev->ring_order); i++ ) gnttab_end_access(dev->intf->ref[i]); - free_pages(dev->data.in, dev->ring_order); + if ( dev->kexecmem ) + kexec_free_mod_pages(kexec_recid, (unsigned long)dev->data.in, + 1 << dev->ring_order); + else + free_pages(dev->data.in, dev->ring_order); } unbind_evtchn(dev->evtchn); gnttab_end_access(dev->ring_ref); - free_page(dev->intf); + if ( dev->kexecmem ) + kexec_free_mod_pages(kexec_recid, (unsigned long)dev->intf, 1); + else + free_page(dev->intf); free(dev->backend); free(dev->tag); + if ( dev =3D=3D kexec_dev ) + kexec_dev =3D NULL; free(dev); } =20 @@ -1111,7 +1132,7 @@ static bool issue_err(struct dev_9pfs *dev, char *msg= , char *reason) return false; } =20 -static bool read_config_xs(struct dev_9pfs *dev) +static bool read_config_xs(struct dev_9pfs *dev, struct kexec_9pfs_rec *re= c) { char *msg; char *reason =3D ""; @@ -1121,7 +1142,9 @@ static bool read_config_xs(struct dev_9pfs *dev) char *v; void *addr; unsigned int i; + unsigned int n_pages; int retry =3D 1; + int err; =20 msg =3D xenbus_read_unsigned(XBT_NIL, dev->nodename, "backend-id", &de= v->dom); if ( msg ) @@ -1177,7 +1200,9 @@ static bool read_config_xs(struct dev_9pfs *dev) return issue_err(dev, msg, reason); } =20 - dev->intf =3D (void *)alloc_page(); + dev->intf =3D (void *)(dev->kexecmem + ? kexec_alloc_mod_pages(kexec_recid, 1) + : alloc_page()); if ( !dev->intf ) { reason =3D "couldn't allocate shared interface page"; @@ -1191,14 +1216,17 @@ static bool read_config_xs(struct dev_9pfs *dev) return issue_err(dev, msg, reason); } dev->intf->ring_order =3D dev->ring_order; - dev->data.in =3D (void *)alloc_pages(dev->ring_order); + n_pages =3D 1 << dev->ring_order; + dev->data.in =3D (void *)(dev->kexecmem + ? kexec_alloc_mod_pages(kexec_recid, n_pages) + : alloc_pages(dev->ring_order)); if ( !dev->data.in ) { reason =3D "couldn't allocate ring pages"; return issue_err(dev, msg, reason); } dev->data.out =3D dev->data.in + XEN_FLEX_RING_SIZE(dev->ring_order); - for ( i =3D 0; i < (1 << dev->ring_order); i++ ) + for ( i =3D 0; i < n_pages; i++ ) { addr =3D dev->data.in + i * PAGE_SIZE; dev->intf->ref[i] =3D gnttab_grant_access(dev->dom, virt_to_mfn(ad= dr), 0); @@ -1256,18 +1284,65 @@ static bool read_config_xs(struct dev_9pfs *dev) if ( msg ) return issue_err(dev, msg, reason); =20 + if ( dev->kexecmem ) + { + rec->ring_ref =3D dev->ring_ref; + rec->evtchn =3D dev->evtchn; + err =3D kexec_upd_mod_record(kexec_recid, KEXECMOD_REC_9PFS, rec, + sizeof(*rec)); + BUG_ON(err); + } + return true; } =20 -void *init_9pfront(unsigned int id, const char *mnt) +#ifdef CONFIG_KEXEC +static int kexec_9pfront(bool undo) +{ + struct kexec_9pfs_rec rec; + + if ( kexec_recid < 0 || !kexec_dev || undo ) + return 0; + + kexec_read_mod_record(kexec_recid, &rec, sizeof(rec)); + rec.prod_pvt_out =3D kexec_dev->prod_pvt_out; + rec.cons_pvt_in =3D kexec_dev->cons_pvt_in; + kexec_upd_mod_record(kexec_recid, KEXECMOD_REC_9PFS, &rec, sizeof(rec)= ); + + return 0; +} +kexec_call(kexec_9pfront); +#endif + +static void read_config_kexec(struct dev_9pfs *dev, struct kexec_9pfs_rec = *rec) +{ + dev->ring_ref =3D rec->ring_ref; + dev->evtchn =3D rec->evtchn; + dev->prod_pvt_out =3D rec->prod_pvt_out; + dev->cons_pvt_in =3D rec->cons_pvt_in; + + dev->intf =3D gnttab_get_addr(dev->ring_ref); + dev->ring_order =3D dev->intf->ring_order; + dev->data.in =3D gnttab_get_addr(dev->intf->ref[0]); + dev->data.out =3D dev->data.in + XEN_FLEX_RING_SIZE(dev->ring_order); + + bind_evtchn(dev->evtchn, intr_9pfs, dev); +} + +void *init_9pfront2(unsigned int id, const char *mnt, unsigned int flags) { struct dev_9pfs *dev; char *reason =3D ""; unsigned int i; + struct kexec_9pfs_rec record =3D { }; + unsigned int rec_size; =20 - printk("9pfsfront add %u, for mount at %s\n", id, mnt); + printk("9pfsfront add %u, for mount at %s, flags %x\n", id, mnt, flags= ); dev =3D malloc(sizeof(*dev)); memset(dev, 0, sizeof(*dev)); + dev->kexecmem =3D flags & (INIT9P_FLAG_KEXEC | INIT9P_FLAG_REINIT); + if ( dev->kexecmem ) + kexec_dev =3D dev; snprintf(dev->nodename, sizeof(dev->nodename), "device/9pfs/%u", id); dev->id =3D id; init_waitqueue_head(&dev->waitq); @@ -1282,12 +1357,25 @@ void *init_9pfront(unsigned int id, const char *mnt) } dev->free_reqs =3D 0; =20 - if ( !read_config_xs(dev) ) - goto err_out; + if ( !(flags & INIT9P_FLAG_REINIT) ) + { + if ( dev->kexecmem ) + kexec_recid =3D kexec_add_mod_record(KEXECMOD_REC_9PFS, &recor= d, + sizeof(record)); + if ( !read_config_xs(dev, &record) ) + goto err_out; + } + else + { + kexec_recid =3D kexec_find_mod_record(0, KEXECMOD_REC_9PFS, &rec_s= ize); + BUG_ON(kexec_recid < 0 || rec_size !=3D sizeof(record)); + kexec_read_mod_record(kexec_recid, &record, rec_size); + read_config_kexec(dev, &record); + } =20 unmask_evtchn(dev->evtchn); =20 - if ( connect_9pfs(dev) ) + if ( connect_9pfs(dev, !(flags & INIT9P_FLAG_REINIT)) ) { reason =3D "9pfs connect failed"; goto err; @@ -1309,6 +1397,12 @@ void *init_9pfront(unsigned int id, const char *mnt) free_9pfront(dev); return NULL; } +EXPORT_SYMBOL(init_9pfront2); + +void *init_9pfront(unsigned int id, const char *mnt) +{ + return init_9pfront2(id, mnt, 0); +} EXPORT_SYMBOL(init_9pfront); =20 void shutdown_9pfront(void *dev) diff --git a/include/9pfront.h b/include/9pfront.h index 722ec564..a0cb5487 100644 --- a/include/9pfront.h +++ b/include/9pfront.h @@ -2,6 +2,15 @@ #define __9PFRONT_H__ =20 void *init_9pfront(unsigned int id, const char *mnt); +void *init_9pfront2(unsigned int id, const char *mnt, unsigned int flags); +#ifdef CONFIG_KEXEC +#define INIT9P_FLAG_REINIT 0x01 /* Reinit with data from kexec module= . */ +#define INIT9P_FLAG_KEXEC 0x02 /* Use kexec module for interface. */ +#else +#define INIT9P_FLAG_REINIT 0 +#define INIT9P_FLAG_KEXEC 0 +#endif + void shutdown_9pfront(void *dev); =20 #endif /* __9PFRONT_H__ */ diff --git a/include/kexec.h b/include/kexec.h index 1e753ee1..b358b202 100644 --- a/include/kexec.h +++ b/include/kexec.h @@ -34,6 +34,7 @@ struct kexec_module_rec { uint16_t offset; /* Offset to record from start of page. = */ uint8_t type; /* Type of record. = */ #define KEXECMOD_REC_NONE 0 +#define KEXECMOD_REC_9PFS 1 uint8_t size; /* Size of record. = */ }; =20 --=20 2.43.0 From nobody Thu Oct 30 23:31:26 2025 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=1751444459; cv=none; d=zohomail.com; s=zohoarc; b=XTt6QJ3+NseauDRpP6oAWUQ+kVrVsVNZyoWhrS5yCioviaE3Go6QtZtU2FP/ht4LVkVZ24AzB3Qe9lsbkRROYYOh3FmhgnjD9vKlRlsLU8qWU2UYNVxtJ3IWs1iUEShoBIjSZmULLMGVcWJyXnIgSWa51puOp2ufEhpfRKMs1dQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751444459; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Dn//+GflyhXs2E0/uE+NcjSGBv2wFdky7ji5ZDIU8Zg=; b=Dmp4FIs6ZJafqYfz2x+IiS5mBaD30e0Zt7kFGex1KebuWQ1MpktSUBr1dmoDRdVBxSL7IrSxmmU3Yug4lrWHeW5dg8Jyk9/UFqwvpQQYUNSIv2r1c8RhmahIjM7/FDTUjzrX2JxmzcTKDXuM1Jd1UHkvn26W9Kwqa+OlowUpkA0= 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 1751444459615329.63472595228984; Wed, 2 Jul 2025 01:20:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1030434.1404112 (Exim 4.92) (envelope-from ) id 1uWshw-0004TE-0P; Wed, 02 Jul 2025 08:20:44 +0000 Received: by outflank-mailman (output) from mailman id 1030434.1404112; Wed, 02 Jul 2025 08:20:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWshv-0004PU-PC; Wed, 02 Jul 2025 08:20:43 +0000 Received: by outflank-mailman (input) for mailman id 1030434; Wed, 02 Jul 2025 08:20:42 +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 1uWsc9-00082Y-CU for xen-devel@lists.xenproject.org; Wed, 02 Jul 2025 08:14:45 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [2a07:de40:b251:101:10:150:64:1]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9c167c35-571c-11f0-a313-13f23c93f187; Wed, 02 Jul 2025 10:14:43 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A0C5C2117F; Wed, 2 Jul 2025 08:14:43 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 6DF4D13A24; Wed, 2 Jul 2025 08:14:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id URBfGXPqZGiXSQAAD6G6ig (envelope-from ); Wed, 02 Jul 2025 08:14:43 +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: 9c167c35-571c-11f0-a313-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444083; 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=Dn//+GflyhXs2E0/uE+NcjSGBv2wFdky7ji5ZDIU8Zg=; b=f7se+NC+/YQxrV6M43+eU/zCuMOd9cu6Lhut6ul6uwQGpvbXSBlfFuc9lyEltMWbEbPEFT nQSrzkXXIDKSpACunye31nFwclpObMGIzKtKGAq9uQwnr3S8kHpyFkbcGMfPg2CwI7m1GQ s1c5iPYajFjhe0zgy0OlmdmsELmyCLA= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1751444083; 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=Dn//+GflyhXs2E0/uE+NcjSGBv2wFdky7ji5ZDIU8Zg=; b=f7se+NC+/YQxrV6M43+eU/zCuMOd9cu6Lhut6ul6uwQGpvbXSBlfFuc9lyEltMWbEbPEFT nQSrzkXXIDKSpACunye31nFwclpObMGIzKtKGAq9uQwnr3S8kHpyFkbcGMfPg2CwI7m1GQ s1c5iPYajFjhe0zgy0OlmdmsELmyCLA= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross Subject: [MINI-OS PATCH 19/19] events: export bind_evtchn() Date: Wed, 2 Jul 2025 10:12:54 +0200 Message-ID: <20250702081254.14383-20-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250702081254.14383-1-jgross@suse.com> References: <20250702081254.14383-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Flag: NO X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.com:mid,suse.com:email]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1751444460758116600 Content-Type: text/plain; charset="utf-8" Export the bind_evtchn() function, as it will be needed for reactivating events after kexec(). Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- events.c | 1 + 1 file changed, 1 insertion(+) diff --git a/events.c b/events.c index 9f3dbf05..a9c1ccac 100644 --- a/events.c +++ b/events.c @@ -98,6 +98,7 @@ evtchn_port_t bind_evtchn(evtchn_port_t port, evtchn_hand= ler_t handler, =20 return port; } +EXPORT_SYMBOL(bind_evtchn); =20 void unbind_evtchn(evtchn_port_t port ) { --=20 2.43.0