From nobody Thu Oct 30 22:56:25 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=1752586211; cv=none; d=zohomail.com; s=zohoarc; b=PPHYIfaNUkMK/ikphArd3QrQu96e6c7408Ry6Ql1FPKVBW9WLpFSPvRXw8hTlKg4BLF2IHanBjwHv+aQs4H5OjmiPaFamvmzkEnkNT88iFee6BjtKvkSg4VE1o9ITpDICC3+ej+6UjBX/J2CCVYQcToUkUIz+vHJ7eHokDNMwyE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752586211; 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=NTu0grqsD74PNEs9r+9EO+DwJ5Ex1gjWiVPjU6SdJuY=; b=Ch3CeGGogPAGlsFQ+vupIrJ/lkj722B2VCDM5ZRmA9XbZweC8Qcd1pHf1WZAJu0Ynjdyn/j5dWWyuvqZLpbxE+hSqzJros7Fo22SWirVBlDXkh7taYbLdSmeoME6uIGvBzaacK6BENj2+HPPFaZT67syUQga950qy83zfSUILWc= 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 1752586211140284.7655571432243; Tue, 15 Jul 2025 06:30:11 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1044115.1414225 (Exim 4.92) (envelope-from ) id 1ubfjG-0001A5-RQ; Tue, 15 Jul 2025 13:29:54 +0000 Received: by outflank-mailman (output) from mailman id 1044115.1414225; Tue, 15 Jul 2025 13:29:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubfjG-00019y-OB; Tue, 15 Jul 2025 13:29:54 +0000 Received: by outflank-mailman (input) for mailman id 1044115; Tue, 15 Jul 2025 13:29:53 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubfjF-0000p6-4k for xen-devel@lists.xenproject.org; Tue, 15 Jul 2025 13:29:53 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [2a07:de40:b251:101:10:150:64:2]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id c8dfc851-617f-11f0-b894-0df219b8e170; Tue, 15 Jul 2025 15:29:50 +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 2FB2E1F44F; Tue, 15 Jul 2025 13:29:48 +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 0673113A68; Tue, 15 Jul 2025 13:29:48 +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 MCIYAMxXdmgJNwAAD6G6ig (envelope-from ); Tue, 15 Jul 2025 13:29:48 +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: c8dfc851-617f-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586188; 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=NTu0grqsD74PNEs9r+9EO+DwJ5Ex1gjWiVPjU6SdJuY=; b=Kpm3VYPWOiYkSIDCJjnnLl0TXzWygPeSylUcOeQomU9E9SHa/mLH6jns/yA0tJs1XGybGH SL039sf3W0Q6hW2KJQL2Siv0NRHvsHpmoy5mKaC55udeWi04Z0mu+HjxjI99t24xbMULdI 5BirFR1rEF0xmVrTJivjkJTTnQ2nFKM= Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=Kpm3VYPW DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586188; 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=NTu0grqsD74PNEs9r+9EO+DwJ5Ex1gjWiVPjU6SdJuY=; b=Kpm3VYPWOiYkSIDCJjnnLl0TXzWygPeSylUcOeQomU9E9SHa/mLH6jns/yA0tJs1XGybGH SL039sf3W0Q6hW2KJQL2Siv0NRHvsHpmoy5mKaC55udeWi04Z0mu+HjxjI99t24xbMULdI 5BirFR1rEF0xmVrTJivjkJTTnQ2nFKM= 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 v2 01/14] mm: don't add module pages to free memory Date: Tue, 15 Jul 2025 15:29:23 +0200 Message-ID: <20250715132936.2798-2-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250715132936.2798-1-jgross@suse.com> References: <20250715132936.2798-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: X-Spam-Flag: NO X-Rspamd-Queue-Id: 2FB2E1F44F X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.com:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCPT_COUNT_THREE(0.00)[4]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:dkim,suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo] X-Spam-Score: -3.01 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1752586214571116600 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 Reviewed-by: Jason Andryuk --- V2: - call pvh_reserve_start_info() from arch_mm_preinit() (Jason Andryuk) --- arch/x86/mm.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/mm.h | 1 + mm.c | 21 +++++++++++++- 3 files changed, 98 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm.c b/arch/x86/mm.c index 26ede6f4..f60e7d58 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 @@ -108,6 +112,42 @@ desc_ptr idt_ptr =3D .base =3D (unsigned long)&idt, }; =20 +#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; +} + void arch_mm_preinit(void *p) { unsigned int pages; @@ -124,6 +164,43 @@ void arch_mm_preinit(void *p) pages =3D e820_get_current_pages(); last_free_pfn =3D e820_get_maxpfn(pages); balloon_set_nr_pages(pages, last_free_pfn); + pvh_reserve_start_info(&first_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); } #endif =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 22:56:25 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=1752586209; cv=none; d=zohomail.com; s=zohoarc; b=Ntkm/mV1u4b9VyWv4qNWr911IfS/AKMLB6wFPOGTx6MdBppkEDENQQA7ZO4vBVItIQUT+QHZyDZzPHaTRdIj4Ao8xHN8KUd83MbCN/stVAvFMpq2kVrbzx5sRWOP9aDw99BLGvbtHcxi5qKgo/ij2t7j0RR7aObgB2XeZe6uK00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752586209; 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=lDLoaippG53vLOL0sHnqy7SiZBuEGT4wELxw+HEbbmQ=; b=FUrZ9pGPLgzr25td4urxf0F4P1bAZ8G1voI0kaZi46T7wl0da43yW0MmBlM+wLx38X6zzgP1RSN/gXIhMjHL1/zaMzy932AKBbroXPL/PHlMRQqVy6MRsU4Q0p3c5l01V5AVykPa7+TPFsdqRym3UIAiscGYwUkC7J+9Ed+8fTo= 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 1752586209769535.3849637303138; Tue, 15 Jul 2025 06:30:09 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1044117.1414239 (Exim 4.92) (envelope-from ) id 1ubfjK-0001Ta-8c; Tue, 15 Jul 2025 13:29:58 +0000 Received: by outflank-mailman (output) from mailman id 1044117.1414239; Tue, 15 Jul 2025 13:29:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubfjK-0001TR-5R; Tue, 15 Jul 2025 13:29:58 +0000 Received: by outflank-mailman (input) for mailman id 1044117; Tue, 15 Jul 2025 13:29:56 +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 1ubfjI-00013q-A2 for xen-devel@lists.xenproject.org; Tue, 15 Jul 2025 13:29:56 +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 cbb70347-617f-11f0-a319-13f23c93f187; Tue, 15 Jul 2025 15:29:55 +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 BAD741F397; Tue, 15 Jul 2025 13:29: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 8C37713A68; Tue, 15 Jul 2025 13:29: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 aVuzINFXdmgRNwAAD6G6ig (envelope-from ); Tue, 15 Jul 2025 13:29: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: cbb70347-617f-11f0-a319-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586193; 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=lDLoaippG53vLOL0sHnqy7SiZBuEGT4wELxw+HEbbmQ=; b=GOF8XqOvO8HKoiA+Kyj4jDiygj8+3WXWB/54GkpnMysYqD0JjxROPKpnWoShEGaddF7mCF uxSbnbxiP6Ulde4qejlA8lkDaK2hP4iXqHePy5XzRgou1uzyRWeOrvyCyliuZlxOIh5iOQ dEYCLnHS8j5fd6a+NHpyGKIE6aroAgI= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586193; 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=lDLoaippG53vLOL0sHnqy7SiZBuEGT4wELxw+HEbbmQ=; b=GOF8XqOvO8HKoiA+Kyj4jDiygj8+3WXWB/54GkpnMysYqD0JjxROPKpnWoShEGaddF7mCF uxSbnbxiP6Ulde4qejlA8lkDaK2hP4iXqHePy5XzRgou1uzyRWeOrvyCyliuZlxOIh5iOQ dEYCLnHS8j5fd6a+NHpyGKIE6aroAgI= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross , Jason Andryuk Subject: [MINI-OS PATCH v2 02/14] kexec: fix physical addresses in start info data Date: Tue, 15 Jul 2025 15:29:24 +0200 Message-ID: <20250715132936.2798-3-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250715132936.2798-1-jgross@suse.com> References: <20250715132936.2798-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: 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]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.com:email,suse.com:mid,amd.com:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -2.80 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1752586211453116600 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. Additionally rename kexec_param_loc to kexec_param_pa to better reflect the semantics of the variable. Fixes: b7994b6409a4 ("mini-os: kexec: build parameters for new kernel") Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- V2: - rename kexec_param_loc to kexec_param_pa (Jason Andryuk) --- arch/x86/kexec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/kexec.c b/arch/x86/kexec.c index fc58473e..d0af460d 100644 --- a/arch/x86/kexec.c +++ b/arch/x86/kexec.c @@ -197,7 +197,7 @@ bool kexec_arch_need_analyze_shdrs(void) return kernel_phys_entry =3D=3D ~0UL; } =20 -static unsigned long kexec_param_loc; +static unsigned long kexec_param_pa; static unsigned int kexec_param_size; static unsigned long kexec_param_mem; =20 @@ -208,7 +208,7 @@ void kexec_set_param_loc(const char *cmdline) kexec_param_size +=3D strlen(cmdline) + 1; =20 kexec_last_addr =3D (kexec_last_addr + 7) & ~7UL; - kexec_param_loc =3D kexec_last_addr; + kexec_param_pa =3D kexec_last_addr; kexec_last_addr +=3D kexec_param_size; kexec_last_addr =3D round_pgup(kexec_last_addr); } @@ -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_pa + 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_pa + sizeof(*info); info->memmap_entries =3D e820_entries; =20 mmap =3D (struct hvm_memmap_table_entry *)(info + 1); @@ -249,13 +249,13 @@ int kexec_get_entry(const char *cmdline) =20 strcpy((char *)mmap, cmdline); =20 - if ( kexec_add_action(KEXEC_COPY, to_virt(kexec_param_loc), info, + if ( kexec_add_action(KEXEC_COPY, to_virt(kexec_param_pa), info, kexec_param_size) ) return ENOSPC; =20 /* The call of the new kernel happens via the physical address! */ if ( kexec_add_action(KEXEC_CALL, (void *)kernel_phys_entry, - (void *)kexec_param_loc, 0) ) + (void *)kexec_param_pa, 0) ) return ENOSPC; =20 return 0; --=20 2.43.0 From nobody Thu Oct 30 22:56:25 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=1752586215; cv=none; d=zohomail.com; s=zohoarc; b=eIeuWVIFKT9sKDbY3/kZ6VhsiWed+Yipm+T9zt1gbC4vBnBvy8Yio56nvWpKoEpJy1C6AQaGAD8AciRiUE1M8OqQNjPNHgKBD0qPm+jLg12fAxDEW3xZnmYc6RvCRBm7D+foVltvG8dpR4SQd99QYMuaBmhcu30lE6JL6ORHrQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752586215; 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=x9TLANKlez8tsN2wKkkD1NspuAsBv9mWQ6EyKJDqy7M=; b=JmUEcA48/u7rWVcL5P3KWSMc849OGOgDaX6RNK2F7DYBP1glvn4sh+oq4H5jyif9MwWtnu9xl5z3RBQZFuAJFU128BtKUqJ8mm7th0Kwh2d8ccdHJORC0WeiLDVQ8XBZx0caeOnZcd/mUBasyq4Fb+ati/N9FTV3mab8jJDcz84= 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 1752586215458322.4866557979889; Tue, 15 Jul 2025 06:30:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1044119.1414249 (Exim 4.92) (envelope-from ) id 1ubfjN-0001mD-Et; Tue, 15 Jul 2025 13:30:01 +0000 Received: by outflank-mailman (output) from mailman id 1044119.1414249; Tue, 15 Jul 2025 13:30:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubfjN-0001m3-Bg; Tue, 15 Jul 2025 13:30:01 +0000 Received: by outflank-mailman (input) for mailman id 1044119; Tue, 15 Jul 2025 13:30:00 +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 1ubfjM-00013q-2m for xen-devel@lists.xenproject.org; Tue, 15 Jul 2025 13:30:00 +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 ce14d656-617f-11f0-a319-13f23c93f187; Tue, 15 Jul 2025 15:29: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 541731F452; Tue, 15 Jul 2025 13:29: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 2440F13A68; Tue, 15 Jul 2025 13:29:59 +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 12lqB9dXdmgeNwAAD6G6ig (envelope-from ); Tue, 15 Jul 2025 13:29:59 +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: ce14d656-617f-11f0-a319-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586199; 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=x9TLANKlez8tsN2wKkkD1NspuAsBv9mWQ6EyKJDqy7M=; b=P0Sr58IXZDYS9lagLZeK0j4k2WZ6T7TS2CPWKg3jSegJIvVCC8/7dUfYFQLxZHjfRNG+iA n6e46D69/yao2bnupS46sHIYTGfX5iVtPrYjeDeczlHvE/bMTyz6ULSEQNU/qgH4WGjkun bx5UURBrtwE5Pa5B8ujRWLUp1yHaayU= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586199; 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=x9TLANKlez8tsN2wKkkD1NspuAsBv9mWQ6EyKJDqy7M=; b=P0Sr58IXZDYS9lagLZeK0j4k2WZ6T7TS2CPWKg3jSegJIvVCC8/7dUfYFQLxZHjfRNG+iA n6e46D69/yao2bnupS46sHIYTGfX5iVtPrYjeDeczlHvE/bMTyz6ULSEQNU/qgH4WGjkun bx5UURBrtwE5Pa5B8ujRWLUp1yHaayU= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross , Jason Andryuk Subject: [MINI-OS PATCH v2 03/14] e820: don't count lapic page as initially reserved Date: Tue, 15 Jul 2025 15:29:25 +0200 Message-ID: <20250715132936.2798-4-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250715132936.2798-1-jgross@suse.com> References: <20250715132936.2798-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: 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]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[amd.com:email,imap1.dmz-prg2.suse.org:helo,suse.com:email,suse.com:mid]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -2.80 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1752586216312116600 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 16622e23..44cfac05 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 22:56:25 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=1752586223; cv=none; d=zohomail.com; s=zohoarc; b=baliAyBQcCysQbW9gXr5pqjIUQ1FW5ySKt/w6B1C6bsbHIcBfLqC5k9tb9gkeWKEOBHUerfCaqAvopzgVwem1Q6bv/+3rYj6HrQ8TdtJJzaVEpKHSirJGwnmeH6qfJEVOjFwIX/2XbjCNB2pA0K4M9t1wN6aU3WtPJmNEh128sw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752586223; 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=ycMxB7C6V9MFY6iKdrBuAK81Hin6bWQs2JTEO7PYpys=; b=ExYT7HpbtuD28wBiVadfNwt0ZgvOG53YIhQl8IHQOgtlqEeN8U4zSemz+p25HRJLlwf20yYqj5MWJDXNn1kpSD/JSrTbQWEh28M+tSZYEzS9blnru69ar51hEyb3n0WhRFlpzNqCXEzh3+jMpyKYbt4yCUQJJQIMCHolx/JuO4w= 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 1752586223486205.84803653927872; Tue, 15 Jul 2025 06:30:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1044135.1414267 (Exim 4.92) (envelope-from ) id 1ubfjU-0003Bz-Sk; Tue, 15 Jul 2025 13:30:08 +0000 Received: by outflank-mailman (output) from mailman id 1044135.1414267; Tue, 15 Jul 2025 13:30:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubfjU-0003Br-PJ; Tue, 15 Jul 2025 13:30:08 +0000 Received: by outflank-mailman (input) for mailman id 1044135; Tue, 15 Jul 2025 13:30:08 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubfjU-0000p6-4O for xen-devel@lists.xenproject.org; Tue, 15 Jul 2025 13:30:08 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [2a07:de40:b251:101:10:150:64:2]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d1838779-617f-11f0-b894-0df219b8e170; Tue, 15 Jul 2025 15:30:05 +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 EE8DC1F769; Tue, 15 Jul 2025 13:30: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 B51FE13A68; Tue, 15 Jul 2025 13:30: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 qfKzKtxXdmhGNwAAD6G6ig (envelope-from ); Tue, 15 Jul 2025 13:30: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: d1838779-617f-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586205; 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=ycMxB7C6V9MFY6iKdrBuAK81Hin6bWQs2JTEO7PYpys=; b=qqG6dvE7L1PDj++98MXqGAx0S7cMJxl9K6qe5gXUiQJaZG2N+vIuoXh1FO9KrxRHDvRtr4 XOgfOcSftBy1DhQ0Ku3dQb3Uy05lgjXoRwfG57ieVoTVLErKKemZOWdUpRDhBV1X28laSZ +bQFeGCMQKAeaC7GrHKw+aHXXFjRzzw= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586204; 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=ycMxB7C6V9MFY6iKdrBuAK81Hin6bWQs2JTEO7PYpys=; b=kkmlP9MVsCHJRKFCUH9ZVd4oSIdSs5Gn3UWppI4+dwSycpDZVLX4Ti7Wxe1LoIkx8imK7s /TU46f/wnH3E5uNsdb4ssw5/pARLU7DMvO/pWah8jXnsPVQzK63rqJ1bR23k9R/Ha16Hih v8j1hGkWJH3nmh3ZcMVXZfcWfCkfgTQ= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross , Jason Andryuk Subject: [MINI-OS PATCH v2 04/14] kexec: restructure building the start info data Date: Tue, 15 Jul 2025 15:29:26 +0200 Message-ID: <20250715132936.2798-5-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250715132936.2798-1-jgross@suse.com> References: <20250715132936.2798-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]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[amd.com:email,imap1.dmz-prg2.suse.org:helo,suse.com:mid,suse.com:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Level: X-Spam-Score: -2.80 X-ZohoMail-DKIM: pass (identity @suse.com) (identity @suse.com) X-ZM-MESSAGEID: 1752586224473116600 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 d0af460d..29f8aa81 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_pa + sizeof(*info) + - e820_entries * sizeof(struct hvm_memmap_table_en= try); - info->memmap_paddr =3D kexec_param_pa + 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_pa + (unsigned long)next - kexec_pa= ram_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_pa + (unsigned long)next - kexec_p= aram_mem; + strcpy(next, cmdline); =20 if ( kexec_add_action(KEXEC_COPY, to_virt(kexec_param_pa), info, kexec_param_size) ) --=20 2.43.0 From nobody Thu Oct 30 22:56:25 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=1752586257; cv=none; d=zohomail.com; s=zohoarc; b=i3OQ6fvDIJaWmHsI4/xVDt6bZbgzMkK7841teKwE63Cp5kwVexV49CnL5Z3kQ9Yt1XP+d5o1LqYCUwY9nZbTeOM05U8vShARE4kwaie33jniqLpcnPcMW5Yh4a+5MWHkINkGUHPB/QQ9l0WpbXU5aYrVcENbJpZuqJWdqJ+a5hk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752586257; 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=B6SWSOlBDneLonJNetlsBzYkrHEyPfegHVWVGLmwK3g=; b=QbyUvytTkCT8mTqNkkhdfgZfSOEVaiOY1Uh0cYPXbwVlHuzieNQ/LzgVyJxfwi2hugsbfkxkwORvnpvsYljQa1PsJVsjzSgr5Fxy++hBhrcfY6EZrkZolO1FFVCJha/rOku+epMeDDos7c3GPYCEbgNodX6jt8rLlcBtfkfaHLo= 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 1752586257589779.4682745773221; Tue, 15 Jul 2025 06:30:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1044163.1414277 (Exim 4.92) (envelope-from ) id 1ubfk5-0004do-51; Tue, 15 Jul 2025 13:30:45 +0000 Received: by outflank-mailman (output) from mailman id 1044163.1414277; Tue, 15 Jul 2025 13:30:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubfk5-0004dh-1t; Tue, 15 Jul 2025 13:30:45 +0000 Received: by outflank-mailman (input) for mailman id 1044163; Tue, 15 Jul 2025 13:30:44 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubfjX-00013q-GY for xen-devel@lists.xenproject.org; Tue, 15 Jul 2025 13:30:11 +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 d4c7f3c8-617f-11f0-a319-13f23c93f187; Tue, 15 Jul 2025 15:30:10 +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 8F8BE21204; Tue, 15 Jul 2025 13:30: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 5510A13A68; Tue, 15 Jul 2025 13:30:10 +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 q/lCE+JXdmhQNwAAD6G6ig (envelope-from ); Tue, 15 Jul 2025 13:30:10 +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: d4c7f3c8-617f-11f0-a319-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586210; 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=B6SWSOlBDneLonJNetlsBzYkrHEyPfegHVWVGLmwK3g=; b=HLelBBGxCaT0BsshA7lxY0tl3kEJvM1WhjX8uru6TwIkWutWG+CoCgnwqjAdOyGoYitGny Wznbo86UumQa9uiqZIaUsvfbfKeVMiJHCrCqnHHLSb5aCYPghnkxZtLhFcjEaCY2Q/A4t0 4v9ekTZ5o0uUkhJXkH494RNIXgROmGI= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586210; 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=B6SWSOlBDneLonJNetlsBzYkrHEyPfegHVWVGLmwK3g=; b=HLelBBGxCaT0BsshA7lxY0tl3kEJvM1WhjX8uru6TwIkWutWG+CoCgnwqjAdOyGoYitGny Wznbo86UumQa9uiqZIaUsvfbfKeVMiJHCrCqnHHLSb5aCYPghnkxZtLhFcjEaCY2Q/A4t0 4v9ekTZ5o0uUkhJXkH494RNIXgROmGI= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross , Jason Andryuk Subject: [MINI-OS PATCH v2 05/14] e820: use special type for software reserved memory Date: Tue, 15 Jul 2025 15:29:27 +0200 Message-ID: <20250715132936.2798-6-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250715132936.2798-1-jgross@suse.com> References: <20250715132936.2798-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 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)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid,amd.com:email,imap1.dmz-prg2.suse.org:helo] X-Spam-Flag: NO X-Spam-Score: -2.80 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1752586258886116600 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 29f8aa81..b33fbfc1 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_pa + (unsigned long)next - kexec_pa= ram_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_pa + (unsigned long)next - kexec_p= aram_mem; diff --git a/e820.c b/e820.c index 44cfac05..1ffeaf00 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 round_pgup(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 22:56:25 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=1752586457; cv=none; d=zohomail.com; s=zohoarc; b=bircqAPXdd/beXrZU/2p+XapD1pqOqUyjcbg4xOu5NQm8iWw23AsaMkhydMwxltx1AOlbvo8SB7aWiUmr6M3MiyaijFBFxNCpMDDMS7Uo2tmeFWyocUYUKUBn9W+abqpQtXMLaUk7e4Mn2zkVp7vDd+vfRrU/AQpPIoTesq7L3I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752586457; 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=0y6tolrzUxQrHWx/8IlHGOKqrdgtUprT6TUKSYQpynQ=; b=HJ98bW74Ras3LF4UY1ybTUUsDdlmgOLPUqs8zGlxgXVwjy0mijWKOFf3wVL+pOWXvvztmkaHRWYo69dvDbeLm5xKTv2+usZ5O0NeKSF27FFJW7uFjQdXBSEitPlmI5NYs5COX5CY33B5nDWmw9Qy6l7WbmII9of2zTiJ6H81+JI= 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 1752586457522992.9702322615703; Tue, 15 Jul 2025 06:34:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1044250.1414326 (Exim 4.92) (envelope-from ) id 1ubfnG-0007tf-GJ; Tue, 15 Jul 2025 13:34:02 +0000 Received: by outflank-mailman (output) from mailman id 1044250.1414326; Tue, 15 Jul 2025 13:34:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubfnG-0007tY-Dn; Tue, 15 Jul 2025 13:34:02 +0000 Received: by outflank-mailman (input) for mailman id 1044250; Tue, 15 Jul 2025 13:34:01 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubfjg-0000p6-6b for xen-devel@lists.xenproject.org; Tue, 15 Jul 2025 13:30:20 +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 d8402f10-617f-11f0-b894-0df219b8e170; Tue, 15 Jul 2025 15:30:16 +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 330CC21204; Tue, 15 Jul 2025 13:30:16 +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 EFE5413A68; Tue, 15 Jul 2025 13:30: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 jlbmOOdXdmhaNwAAD6G6ig (envelope-from ); Tue, 15 Jul 2025 13:30: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: d8402f10-617f-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586216; 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=0y6tolrzUxQrHWx/8IlHGOKqrdgtUprT6TUKSYQpynQ=; b=m4OQMCDEdQ8Q2/LemCbTQ+Gq+C83J+toOJf7ct1vK4rcVkI7bqGrkUoeIk1YIj/fZom61m c1DTFC0mJws10bv4Ype5QiArxyxkdmjuN9KaiHnUge2dSt4/CvDBQHAUaS03gblcHJ4l1I Z0pH5LfRlpfmi8Z2fMhqBo1EA69WpNA= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=m4OQMCDE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586216; 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=0y6tolrzUxQrHWx/8IlHGOKqrdgtUprT6TUKSYQpynQ=; b=m4OQMCDEdQ8Q2/LemCbTQ+Gq+C83J+toOJf7ct1vK4rcVkI7bqGrkUoeIk1YIj/fZom61m c1DTFC0mJws10bv4Ype5QiArxyxkdmjuN9KaiHnUge2dSt4/CvDBQHAUaS03gblcHJ4l1I Z0pH5LfRlpfmi8Z2fMhqBo1EA69WpNA= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross , Jan Beulich Subject: [MINI-OS PATCH v2 06/14] mini-os: config: add support for config items with numerical values Date: Tue, 15 Jul 2025 15:29:28 +0200 Message-ID: <20250715132936.2798-7-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250715132936.2798-1-jgross@suse.com> References: <20250715132936.2798-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: X-Spam-Flag: NO X-Rspamd-Queue-Id: 330CC21204 X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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)[]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; TO_DN_SOME(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]; ARC_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.com:+]; RCPT_COUNT_FIVE(0.00)[5]; DBL_BLOCKED_OPENRESOLVER(0.00)[config.mk:url,suse.com:dkim,suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo] X-Spam-Score: -3.01 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1752586459244116600 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 22:56:25 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=1752586494; cv=none; d=zohomail.com; s=zohoarc; b=ag9Wmt+JW3HeDfUcYAhfpHEnSA8Ru8eWh/OJ3fyEWYR6ArHqL8esJcEI6GrA53AV+Ry892rvY2RNYZG9OW0xpxJHTtCKjnpqYzwqoaBZkvgo2fvwTN1nef/CSxVyZplutjzF+dbyW4erRion5UOSBS1f41g+HI7yn8P/b80+X7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752586494; 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=oBjjfWuh5HXNSeK9rtf2P0Bn6GxDYqshVshwDQxxP10=; b=YngBcXrDsxbyEvTautDP69eOtLFOn6DnrumbgyY/Q3L7BAjRLVZQcq2R4n2xvco/ZHPg9Ytf6SrBtzjQePNfOBFg5uyD1YmQWZbaHFso4QWCtwPQ/IjyPcdVsgUzdCpPf1KIYCPYBaJtfJL34pEj7mivvLEIkmIOCDeHCZ5A4XU= 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 1752586494736997.5131144508015; Tue, 15 Jul 2025 06:34:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1044267.1414337 (Exim 4.92) (envelope-from ) id 1ubfnt-0000JZ-OV; Tue, 15 Jul 2025 13:34:41 +0000 Received: by outflank-mailman (output) from mailman id 1044267.1414337; Tue, 15 Jul 2025 13:34:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubfnt-0000JS-Lp; Tue, 15 Jul 2025 13:34:41 +0000 Received: by outflank-mailman (input) for mailman id 1044267; Tue, 15 Jul 2025 13:34:40 +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 1ubfji-00013q-OR for xen-devel@lists.xenproject.org; Tue, 15 Jul 2025 13:30: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 db7a5889-617f-11f0-a319-13f23c93f187; Tue, 15 Jul 2025 15:30:22 +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 C49BB1F44F; Tue, 15 Jul 2025 13:30: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 9A80213A68; Tue, 15 Jul 2025 13:30: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 cEFcJO1XdmhhNwAAD6G6ig (envelope-from ); Tue, 15 Jul 2025 13:30: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: db7a5889-617f-11f0-a319-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586221; 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=oBjjfWuh5HXNSeK9rtf2P0Bn6GxDYqshVshwDQxxP10=; b=SELp9Fi10Tbk9XMOnXA92SIxmcPRIOfBbv4HcO8pwQ5nSIo1ynRIK1TbNlLc9gvxKSHmok p3AxWHCw/sg6Pkad4Z8ShvyNh/j2WLBtkmti31D32V4J2ytaXUC+bFx219ek0EJNIuS98G 77Sw0lpIrsq+1lVvgg7tN3boFRv/3Ek= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586221; 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=oBjjfWuh5HXNSeK9rtf2P0Bn6GxDYqshVshwDQxxP10=; b=SELp9Fi10Tbk9XMOnXA92SIxmcPRIOfBbv4HcO8pwQ5nSIo1ynRIK1TbNlLc9gvxKSHmok p3AxWHCw/sg6Pkad4Z8ShvyNh/j2WLBtkmti31D32V4J2ytaXUC+bFx219ek0EJNIuS98G 77Sw0lpIrsq+1lVvgg7tN3boFRv/3Ek= 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 v2 07/14] mini-os: kexec: add support for handing over some memory across kexec Date: Tue, 15 Jul 2025 15:29:29 +0200 Message-ID: <20250715132936.2798-8-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250715132936.2798-1-jgross@suse.com> References: <20250715132936.2798-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 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)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[config.mk:url,imap1.dmz-prg2.suse.org:helo,suse.com:email,suse.com:mid] X-Spam-Flag: NO X-Spam-Score: -2.80 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1752586496157116600 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 Reviewed-by: Jason Andryuk --- V2: - set kexec_mod_start in kexec_check_module() - remove fallback definition of CONFIG_KEXEC_MODULE_PAGES (Jan Beulich) - fix mod_ptr->recs_off alignment (Jason Andryuk) - expand comment at start of kexec.h (Jason Andryuk) --- Config.mk | 2 ++ arch/x86/kexec.c | 79 +++++++++++++++++++++++++++++++++++++++++++ arch/x86/mm.c | 18 ++++++++++ arch/x86/setup.c | 28 +++++++++++++++ include/kernel.h | 1 + include/kexec.h | 69 +++++++++++++++++++++++++++++++++++++ include/x86/arch_mm.h | 1 + kexec.c | 3 ++ mm.c | 6 ++++ 9 files changed, 207 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 b33fbfc1..8c9f8a3c 100644 --- a/arch/x86/kexec.c +++ b/arch/x86/kexec.c @@ -201,10 +201,75 @@ static unsigned long kexec_param_pa; 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; + + /* Kexec 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; + + kexec_mod_start =3D mod; + + 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) + + mod_ptr->n_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 +283,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 +318,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_pa + + (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_pa + (unsigned long)next - kexec_p= aram_mem; strcpy(next, cmdline); =20 diff --git a/arch/x86/mm.c b/arch/x86/mm.c index f60e7d58..ebc85e0d 100644 --- a/arch/x86/mm.c +++ b/arch/x86/mm.c @@ -188,6 +188,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..b38a9f54 100644 --- a/include/kexec.h +++ b/include/kexec.h @@ -2,6 +2,72 @@ #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 is usually placed towards the end of memory in order to not + * conflict with the load address of the new kernel. In order to allow fo= r a + * resize by the new kernel after kexec(), the admin data described by str= uct + * kexec_module is located at the start of the last page of the module. T= his + * allows to add additional pages towards lower addresses. + * + * The kexec module (if configured) is being allocated at boot time in case + * no kexec module has been passed to the kernel. If a kexec module has b= een + * passed to the kernel, it is kept and will be passed on by kexec(). + * + * The module can contain two different kinds of information: records and + * pages. + * + * A component wanting to hand over information to the new kernel needs to + * allocate one or more records. The layout of a record is defined by the + * component using it, the layout can be changed only in a compatible way. + * + * The kexec module can contain records of multiple components. Each reco= rd + * type has a unique id which is being used to find the record in the new + * kernel instance. + * + * A record is meant to contain small amounts of information, as all recor= ds + * need to fit into the last page of the kexec module. In case more data + * needs to be handed over, one or multiple pages can be allocated within = the + * kexec module. Module page allocations need to be done with the id of a + * previously allocated record, which will usually contain some information + * related to the allocated page(s). + * + * All references within the kexec module are coded as offsets relative to= the + * start of the last module page. + * + * 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[]; /* Mapping of module pages to associated modul= e */ + /* record. Allocated pages are indicated by = */ + /* their record number (starting from 0). Fre= e */ + /* 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. = */ +}; + +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 +126,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 22:56:25 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=1752586352; cv=none; d=zohomail.com; s=zohoarc; b=m7FptZaiske6k1t29tC4ThA3w5vZc4i7BssF7WmIsjiw2cXFdRJ7TAC4qomn2rvAfwss7ycxpkN+icu7F+iXbO2WvZya1NzlIRmeiAmcB0AoOcFue+RqEucfFoK36KTB/YxYVOmOvqq0CuFKhuHl4ItZOvna7PmhAy3LsjEmI5g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752586352; 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=dQG0ZTeiRyc26Tqw3qcZ1Dj3k6IjcIiutErlineQVn4=; b=DyBT70jSfkpq3p1gKxSvZAbfGqkrdEUv/SXHhPGJxz06ZjmnW9SWXMWY4EGYpH6eaPb0XqkaBydcgYWgKm+1zR957JOZS1L1huL3bChhWpV6Hplz6PdGWW+JAHpcnt7VAnIiwRl/59pchZwpKcmz+b7dehbFucLBTihaXPhUGN0= 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 1752586352192602.4482288385137; Tue, 15 Jul 2025 06:32:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1044184.1414296 (Exim 4.92) (envelope-from ) id 1ubflb-0006F9-SX; Tue, 15 Jul 2025 13:32:19 +0000 Received: by outflank-mailman (output) from mailman id 1044184.1414296; Tue, 15 Jul 2025 13:32:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubflb-0006F2-Pr; Tue, 15 Jul 2025 13:32:19 +0000 Received: by outflank-mailman (input) for mailman id 1044184; Tue, 15 Jul 2025 13:32:19 +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 1ubfjr-0000p6-B8 for xen-devel@lists.xenproject.org; Tue, 15 Jul 2025 13:30:31 +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 deddae55-617f-11f0-b894-0df219b8e170; Tue, 15 Jul 2025 15:30:27 +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 7753621204; Tue, 15 Jul 2025 13:30:27 +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 3E4B413A68; Tue, 15 Jul 2025 13:30:27 +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 CqNVDfNXdmhuNwAAD6G6ig (envelope-from ); Tue, 15 Jul 2025 13:30:27 +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: deddae55-617f-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586227; 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=dQG0ZTeiRyc26Tqw3qcZ1Dj3k6IjcIiutErlineQVn4=; b=NZ2ORD1YgOxFUDEQktZudNsTB9rkqxzOvgAcbLZzEyNGLXQu53e+b6Je6NJdmPTVcCK1Fg xEcWFNL09prPaYlxoLmIDRUjOZxPZIJtYlSH332HGKkHrKg2eMatccnZku4uU/3i8sMEtA ZZ9CqEWjqDzOpjrpRhZAZtrKkxBO/l4= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586227; 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=dQG0ZTeiRyc26Tqw3qcZ1Dj3k6IjcIiutErlineQVn4=; b=NZ2ORD1YgOxFUDEQktZudNsTB9rkqxzOvgAcbLZzEyNGLXQu53e+b6Je6NJdmPTVcCK1Fg xEcWFNL09prPaYlxoLmIDRUjOZxPZIJtYlSH332HGKkHrKg2eMatccnZku4uU/3i8sMEtA ZZ9CqEWjqDzOpjrpRhZAZtrKkxBO/l4= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross , Jason Andryuk Subject: [MINI-OS PATCH v2 08/14] kexec: add support for allocating pages from kexec module memory Date: Tue, 15 Jul 2025 15:29:30 +0200 Message-ID: <20250715132936.2798-9-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250715132936.2798-1-jgross@suse.com> References: <20250715132936.2798-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: 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]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.com:email,suse.com:mid,amd.com:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -2.80 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1752586354528116600 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 8c9f8a3c..e48df3f5 100644 --- a/arch/x86/kexec.c +++ b/arch/x86/kexec.c @@ -240,6 +240,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 ) @@ -257,11 +260,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) + mod_ptr->n_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 b38a9f54..0e0b1a4d 100644 --- a/include/kexec.h +++ b/include/kexec.h @@ -67,6 +67,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 { @@ -80,6 +83,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[]; @@ -129,4 +143,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 22:56:25 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=1752586258; cv=none; d=zohomail.com; s=zohoarc; b=fhvyPwmg7NgK06LOvry+olF8H7v0TxdqV5IyG60+8/ZJGgrtSUNv6CYhWA9HISMFMPdHxERf3KcsHIaXlK/nqasa8ekQ6D6fBnWzXwegJLbmeZinc6O8m0svmYCTubv2EUB97jvF1K4KjMdhwxTW9Wm1U013xfZjr4yv0ofvkzE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752586258; 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=BDdRGnWTd5zwdCL0TVOinfUW7FrCL8NCA12iHuDre8E=; b=TnPsx9V1bu6SejHaOIhPrcMItuZSovVu3gIO5x7AZ/ZwG4mhPv6tb9EvUC1r/Vt7yl7P2rccQJdk/Kt95kztQGbaxd2vlAp5SOzLOmDy+Nfsdx79RYieAe0zhsuB1qDPCBP0Qpf1HzOo+55SCoBPAF1ZSETwpTS+s02S4rm9iJI= 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 1752586258606241.46312642124826; Tue, 15 Jul 2025 06:30:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1044166.1414281 (Exim 4.92) (envelope-from ) id 1ubfk5-0004g7-Eq; Tue, 15 Jul 2025 13:30:45 +0000 Received: by outflank-mailman (output) from mailman id 1044166.1414281; Tue, 15 Jul 2025 13:30:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubfk5-0004ff-9P; Tue, 15 Jul 2025 13:30:45 +0000 Received: by outflank-mailman (input) for mailman id 1044166; Tue, 15 Jul 2025 13:30:44 +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 1ubfjv-0000p6-1I for xen-devel@lists.xenproject.org; Tue, 15 Jul 2025 13:30:35 +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 e247bf86-617f-11f0-b894-0df219b8e170; Tue, 15 Jul 2025 15:30: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 1663421232; Tue, 15 Jul 2025 13:30:33 +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 DAE2C13A68; Tue, 15 Jul 2025 13:30: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 5crsM/hXdmh1NwAAD6G6ig (envelope-from ); Tue, 15 Jul 2025 13:30: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: e247bf86-617f-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586233; 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=BDdRGnWTd5zwdCL0TVOinfUW7FrCL8NCA12iHuDre8E=; b=nYNcCmldwPuW2gGg9URjLy87kYhJtYKeUWCY8VaL/SJCLJ4ny3UkbrGbI+r9yxTSUIDX3P isr/+bd8i2zZyd8n0mSwr4V5+5tsPY447T52puZEHLEhrYZkBmiQnNBvRkNptxGbcOYtb/ uNaKVmMpHnjYivtcpItwBfu2CmYW9VA= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=nYNcCmld DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586233; 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=BDdRGnWTd5zwdCL0TVOinfUW7FrCL8NCA12iHuDre8E=; b=nYNcCmldwPuW2gGg9URjLy87kYhJtYKeUWCY8VaL/SJCLJ4ny3UkbrGbI+r9yxTSUIDX3P isr/+bd8i2zZyd8n0mSwr4V5+5tsPY447T52puZEHLEhrYZkBmiQnNBvRkNptxGbcOYtb/ uNaKVmMpHnjYivtcpItwBfu2CmYW9VA= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross , Jason Andryuk Subject: [MINI-OS PATCH v2 09/14] 9pfs: store bepath in struct struct dev_9pfs Date: Tue, 15 Jul 2025 15:29:31 +0200 Message-ID: <20250715132936.2798-10-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250715132936.2798-1-jgross@suse.com> References: <20250715132936.2798-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: X-Spam-Flag: NO X-Rspamd-Queue-Id: 1663421232 X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; 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)[]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; TO_DN_SOME(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]; ARC_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.com:+]; RCPT_COUNT_FIVE(0.00)[5]; DBL_BLOCKED_OPENRESOLVER(0.00)[amd.com:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.com:dkim,suse.com:mid,suse.com:email] X-Spam-Score: -3.01 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1752586261026116600 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 22:56:25 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=1752587224; cv=none; d=zohomail.com; s=zohoarc; b=bw5zKetwyg7Ny9X4vugLPanHpNlRLLxD/Baph/IP0kYt9k6eFMO49jsyYU0EeyOqsWgipRw5nFwvRSnbo8GgwHtPBQGqgFHkC0oYTh+4DrUe42mSy1KfLeOCfL0vgja7kqHH5qUAmHi/ZgSrfVkWBqohtoSAw2GOpS/Adanvh8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752587224; 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=38MURIeQcvW07nQrk81rmZlwZXuyDK1rVnhs1KCrhZU=; b=NLZk1+/Q62LSEPyzn/zwwNFyz/KBfcUAAWxHl8IUA8zLuq3L/Cg4UylUlFlscbzsL03kqYfupylAZfGX5NaF5JieV9aCFCiPwT4xKhOsEctPIgUshu6fvmxDiMWHWUucedUQIuGefpTXfwV8V0QbtxpcjDNprv1JxRjPtJznI24= 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 1752587224618378.1850787359216; Tue, 15 Jul 2025 06:47:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1044373.1414468 (Exim 4.92) (envelope-from ) id 1ubfzc-0000Rg-Uo; Tue, 15 Jul 2025 13:46:48 +0000 Received: by outflank-mailman (output) from mailman id 1044373.1414468; Tue, 15 Jul 2025 13:46:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubfzc-0000Qz-QD; Tue, 15 Jul 2025 13:46:48 +0000 Received: by outflank-mailman (input) for mailman id 1044373; Tue, 15 Jul 2025 13:46:48 +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 1ubfjz-00013q-Ld for xen-devel@lists.xenproject.org; Tue, 15 Jul 2025 13:30:39 +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 e59bd944-617f-11f0-a319-13f23c93f187; Tue, 15 Jul 2025 15:30:39 +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 B39C71F397; Tue, 15 Jul 2025 13:30: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 806B713A68; Tue, 15 Jul 2025 13:30:38 +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 lObKHf5XdmiMNwAAD6G6ig (envelope-from ); Tue, 15 Jul 2025 13:30:38 +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: e59bd944-617f-11f0-a319-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586238; 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=38MURIeQcvW07nQrk81rmZlwZXuyDK1rVnhs1KCrhZU=; b=c1vpseNsi/SwDGMMkhljgTGs3AMj5ICaSrIboJX8YcQ0pIvkoSY80isEOnycFVXnUV0x5N wpQ3RWLmXMcy4Q/JQ5mCJwsRiwDxK8mh/pFCkFIOL42lWO2O2pWcD1lyydM5BBsktH+0HR PlEGu0dVgqBoPdkzW2wG+C8u193crjs= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586238; 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=38MURIeQcvW07nQrk81rmZlwZXuyDK1rVnhs1KCrhZU=; b=c1vpseNsi/SwDGMMkhljgTGs3AMj5ICaSrIboJX8YcQ0pIvkoSY80isEOnycFVXnUV0x5N wpQ3RWLmXMcy4Q/JQ5mCJwsRiwDxK8mh/pFCkFIOL42lWO2O2pWcD1lyydM5BBsktH+0HR PlEGu0dVgqBoPdkzW2wG+C8u193crjs= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross , Jason Andryuk Subject: [MINI-OS PATCH v2 10/14] 9pfs: refactor init_9pfront() Date: Tue, 15 Jul 2025 15:29:32 +0200 Message-ID: <20250715132936.2798-11-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250715132936.2798-1-jgross@suse.com> References: <20250715132936.2798-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]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.com:mid,suse.com:email,amd.com:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Level: X-Spam-Score: -2.80 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1752587226577116600 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. Don't use gnttab_alloc_and_grant(), as this will hard code to use dom0 as backend. 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 22:56:25 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=1752586892; cv=none; d=zohomail.com; s=zohoarc; b=IXmz7N+5VtSrNKCu0kNQjCjUc4eSQgfKC1U3AKhv6/tX15/OB1Gruox3O0kdF3yZrlZqa0/aCrfPPC3/1fSEqWp74DqRHyrG1Rm0pPXwuMI/QJnQF7n2f/bvgWijTCjKe7iI+fu49k8N/03v1kPwv9PYOpclwhbdqdkadv1sjPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752586892; 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=GLfH1LKxnn3oOigKVk3XV6ShMXvMzS6b7PXnQ2kQXXs=; b=f68VAz95D1G96BNkiqjdzU5AJk4hqTLz4B/AG5/iDKzS0vk+C+EAW6rpKj7b/YFkAoHCaIAGEhVvlu5DYXhWj0Jw5Q10G8aIPL5naNEnpmQ0ozjQGPX6HUOrxf8vpKA5cZcdvpqTZARtN8fw3MviLgVFCsNT1XVlZ37jXx9q48w= 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 1752586892231516.1858679086031; Tue, 15 Jul 2025 06:41:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1044281.1414351 (Exim 4.92) (envelope-from ) id 1ubfuD-00028x-JT; Tue, 15 Jul 2025 13:41:13 +0000 Received: by outflank-mailman (output) from mailman id 1044281.1414351; Tue, 15 Jul 2025 13:41:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubfuD-00028q-GY; Tue, 15 Jul 2025 13:41:13 +0000 Received: by outflank-mailman (input) for mailman id 1044281; Tue, 15 Jul 2025 13:41:11 +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 1ubfk6-0000p6-4B for xen-devel@lists.xenproject.org; Tue, 15 Jul 2025 13:30:46 +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 e8ecb76c-617f-11f0-b894-0df219b8e170; Tue, 15 Jul 2025 15:30:44 +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 4D18721239; Tue, 15 Jul 2025 13:30:44 +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 1D93113A68; Tue, 15 Jul 2025 13:30:44 +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 KgO3BQRYdmiXNwAAD6G6ig (envelope-from ); Tue, 15 Jul 2025 13:30:44 +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: e8ecb76c-617f-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586244; 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=GLfH1LKxnn3oOigKVk3XV6ShMXvMzS6b7PXnQ2kQXXs=; b=p/7QFB4nJJxHcGoO0p90ZsKb8AQ/FSSiNolqN547AV75koHJ6BbNHONl0s8FKPY8SE2pJD 2BInMhZvaBE+aSacd8h0k1od6iUxKwCLJ/txB40uX9bJu7NlItJIxT4LUX/UreB545gOq+ MQdF0loPTarsPNO7ErzDs6qoyH05vL0= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b="p/7QFB4n" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586244; 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=GLfH1LKxnn3oOigKVk3XV6ShMXvMzS6b7PXnQ2kQXXs=; b=p/7QFB4nJJxHcGoO0p90ZsKb8AQ/FSSiNolqN547AV75koHJ6BbNHONl0s8FKPY8SE2pJD 2BInMhZvaBE+aSacd8h0k1od6iUxKwCLJ/txB40uX9bJu7NlItJIxT4LUX/UreB545gOq+ MQdF0loPTarsPNO7ErzDs6qoyH05vL0= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross , Jason Andryuk Subject: [MINI-OS PATCH v2 11/14] gnttab: remove gnttab_alloc_and_grant() function Date: Tue, 15 Jul 2025 15:29:33 +0200 Message-ID: <20250715132936.2798-12-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250715132936.2798-1-jgross@suse.com> References: <20250715132936.2798-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%]; 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)[]; MIME_TRACE(0.00)[0:+]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; TO_DN_SOME(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; ARC_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.com:+]; RCPT_COUNT_FIVE(0.00)[5]; DBL_BLOCKED_OPENRESOLVER(0.00)[amd.com:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.com:mid,suse.com:dkim,suse.com:email] X-Spam-Flag: NO X-Spam-Level: X-Rspamd-Queue-Id: 4D18721239 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -3.01 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1752586892874116600 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 22:56:25 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=1752587136; cv=none; d=zohomail.com; s=zohoarc; b=D5MGJ2mPefhqlwjDR+55pIuUBB+azITgf8iFtWjbH6HYAWbC4GOSaiXpTPi8UNxTVeOsHRQ7lCmGRDWKUpastDsUra4Nx9vvIcFpAdI9b/GgizgG/Ho9LeWQT7Aozy3eUOWw7/gNBRuBNoMDHZaodrpE0pScfY1tptrQuyW+WLc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752587136; 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=qDdBMgPeFsba0l0VzAB0puq0dCuMoWTPG49f+ImrdcA=; b=cB5RWZT6XnG3yPl7g2KLRLTbj069+EmBNAwrk0/FgTbvfsruOfkJfbZj1a+HqVnkgCMq26LLrZ8FTA7lasee/LY/z/YYZmZ/14y+cJBRnj1hRXMXKrFTFKH92bQFLDbPgQsupVYxeIseku+ylumtOOYgVJc97WDhJy273AYWym8= 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 1752587136815912.8955464148087; Tue, 15 Jul 2025 06:45:36 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1044334.1414402 (Exim 4.92) (envelope-from ) id 1ubfyG-0005Fx-S6; Tue, 15 Jul 2025 13:45:24 +0000 Received: by outflank-mailman (output) from mailman id 1044334.1414402; Tue, 15 Jul 2025 13:45:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubfyG-0005Fq-PW; Tue, 15 Jul 2025 13:45:24 +0000 Received: by outflank-mailman (input) for mailman id 1044334; Tue, 15 Jul 2025 13:45:23 +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 1ubfkA-00013q-Pj for xen-devel@lists.xenproject.org; Tue, 15 Jul 2025 13:30:50 +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 ec4fa9b5-617f-11f0-a319-13f23c93f187; Tue, 15 Jul 2025 15:30:50 +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 E34731F7C8; Tue, 15 Jul 2025 13:30:49 +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 B18BE13A68; Tue, 15 Jul 2025 13:30:49 +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 jdP5KQlYdmihNwAAD6G6ig (envelope-from ); Tue, 15 Jul 2025 13:30:49 +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: ec4fa9b5-617f-11f0-a319-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586249; 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=qDdBMgPeFsba0l0VzAB0puq0dCuMoWTPG49f+ImrdcA=; b=LmdRnlhEs6TXrS+snNhPQYHPcF+kgZ2u3X1P+LE40RH8d7w/IPWOzdynZX4LktCkzywV1s bVsnTLEgf3G9aDTBI7zFT4zmDMKS90Xhz41fVTCv0VxTuSjKzwseEdEyQ/yuQMTeXZJRdX Fwx5jZZeZWDTKYresiqaiqCzkipp5/8= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586249; 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=qDdBMgPeFsba0l0VzAB0puq0dCuMoWTPG49f+ImrdcA=; b=LmdRnlhEs6TXrS+snNhPQYHPcF+kgZ2u3X1P+LE40RH8d7w/IPWOzdynZX4LktCkzywV1s bVsnTLEgf3G9aDTBI7zFT4zmDMKS90Xhz41fVTCv0VxTuSjKzwseEdEyQ/yuQMTeXZJRdX Fwx5jZZeZWDTKYresiqaiqCzkipp5/8= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross , Jason Andryuk Subject: [MINI-OS PATCH v2 12/14] gnttab: add function to obtain memory address from grantref Date: Tue, 15 Jul 2025 15:29:34 +0200 Message-ID: <20250715132936.2798-13-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250715132936.2798-1-jgross@suse.com> References: <20250715132936.2798-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: 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]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[amd.com:email,imap1.dmz-prg2.suse.org:helo,suse.com:email,suse.com:mid]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -2.80 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1752587137608116600 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 22:56:25 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=1752587225; cv=none; d=zohomail.com; s=zohoarc; b=Gip/12ENdSdeAETWmgiM5fz72MlTsdgewY4Wsemq+zbaIetUPiArQubjCnzEzOL0uz0TqP6E9t6BiQZHdt8ZBdVw53ZJCqYdfGDH/4rDRjGVwMt/+pvytaNVmCQq3onuySjufWC/LIJ6P474pX09NGHX2Lipfl944zceTcxctsY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752587225; 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=hRAM08+RsDuhPyXv0NnzQdGBRwKZEE1NwpnhwhZY1kI=; b=BNtB9/aJadhEjLT99zQcEPYJd0D0ZxjpArXFaf7kdhCpVy/z4YB1QwIY/dONnC4fLiVWARzdQvB94KOd9fDVnIVwPBStKpTSpPiungxOx8plYXul4UNWB6vRgcmkJO+eelY++SSFxlhEAbKvDuNjUde4rD+wGvMmee90HJjwZ98= 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 175258722531052.542492174943845; Tue, 15 Jul 2025 06:47:05 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1044372.1414463 (Exim 4.92) (envelope-from ) id 1ubfzc-0000Of-MC; Tue, 15 Jul 2025 13:46:48 +0000 Received: by outflank-mailman (output) from mailman id 1044372.1414463; Tue, 15 Jul 2025 13:46:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ubfzc-0000OY-J8; Tue, 15 Jul 2025 13:46:48 +0000 Received: by outflank-mailman (input) for mailman id 1044372; Tue, 15 Jul 2025 13:46:48 +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 1ubfkH-00013q-G6 for xen-devel@lists.xenproject.org; Tue, 15 Jul 2025 13:30:57 +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 f032645e-617f-11f0-a319-13f23c93f187; Tue, 15 Jul 2025 15:30:56 +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 843B721204; Tue, 15 Jul 2025 13:30:55 +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 55E4913A68; Tue, 15 Jul 2025 13:30:55 +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 SpCUEw9Ydmi4NwAAD6G6ig (envelope-from ); Tue, 15 Jul 2025 13:30:55 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f032645e-617f-11f0-a319-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586256; 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=hRAM08+RsDuhPyXv0NnzQdGBRwKZEE1NwpnhwhZY1kI=; b=czyLtKC/4apootecF9icytHIoHa0Kv34P32ozcD39gFmaWi9oa7P8kVXqhtg5P/vK0WoXW yw8tsOZWIrBoB/Gp8LH3zGLH9HYPJLryzaEA8cXc1SePVGfZczy8NHEX/cbda23ggz3SOg VkDBlxcW5jJCBc9R9Cc/Yc1ovRlEAIY= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=ogtWD3F3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586255; 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=hRAM08+RsDuhPyXv0NnzQdGBRwKZEE1NwpnhwhZY1kI=; b=ogtWD3F3SCbMTuMQPElx1+pug0hrUlsNm8lu/XlSrCBsqlohAQCCl4R4pVdL/YTY8VhzWC NJYI4LUBwvWxUZwQ739YLAPfX0F7fCxN80DTSsXCMs9Pt6F84UwYOI0G39zjHKdi+3Sr9W 96Eb5dF2Do1G4Dn950Cm2AKXdiz4Re0= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross , Jason Andryuk Subject: [MINI-OS PATCH v2 13/14] 9pfs: add support to keep device opened across kexec Date: Tue, 15 Jul 2025 15:29:35 +0200 Message-ID: <20250715132936.2798-14-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250715132936.2798-1-jgross@suse.com> References: <20250715132936.2798-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: X-Spam-Flag: NO X-Rspamd-Queue-Id: 843B721204 X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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)[]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; TO_DN_SOME(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]; ARC_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.com:+]; RCPT_COUNT_FIVE(0.00)[5]; DBL_BLOCKED_OPENRESOLVER(0.00)[amd.com:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.com:dkim,suse.com:mid,suse.com:email] X-Spam-Score: -3.01 X-ZohoMail-DKIM: pass (identity @suse.com) (identity @suse.com) X-ZM-MESSAGEID: 1752587226573116600 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 0e0b1a4d..93dd9498 100644 --- a/include/kexec.h +++ b/include/kexec.h @@ -62,6 +62,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 22:56:25 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=1752586982; cv=none; d=zohomail.com; s=zohoarc; b=mUhvgd00i5yTy0/3jQcBoo9PmDGyrbKTOv4hekUxpQBtB430CG3NM+BamZfwlVUGnVZhuBZJnu6ZhDxRLnRJ3ChknYeXh1J7Ky3ln7AW0mUvIQ4O0HYfIf40BFPIYx1+lTUoTmfF4M5aiE0NE+gQbaYp0ODTKV/fEx80H0UwJVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752586982; 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=k9Ov6pkpfp6346PXkACunqlof0M0Xfob950IWGq5/2o=; b=Zqweq9NFsW8PIvK5znk1PDSP8pQcO8HJmshSooBK+Qm3zUf0z9u4cBFh/RQPCvnpB4hmGFcx2TKIUW/GdBtr6agpP7q6TUnDjFn7ARrduruAyUGeRd83EKWIw3Dy0Fp+sSjzahn5Kc/Rkkl/JonPU+hm/NGogR0wYLke1ZX4mZI= 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 1752586982606676.3957095669139; Tue, 15 Jul 2025 06:43:02 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1044313.1414379 (Exim 4.92) (envelope-from ) id 1ubfvm-0003gd-5f; Tue, 15 Jul 2025 13:42:50 +0000 Received: by outflank-mailman (output) from mailman id 1044313.1414379; Tue, 15 Jul 2025 13:42: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 1ubfvm-0003gW-2i; Tue, 15 Jul 2025 13:42:50 +0000 Received: by outflank-mailman (input) for mailman id 1044313; Tue, 15 Jul 2025 13:42: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 1ubfkM-00013q-HK for xen-devel@lists.xenproject.org; Tue, 15 Jul 2025 13:31:02 +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 f2f58e76-617f-11f0-a319-13f23c93f187; Tue, 15 Jul 2025 15:31:01 +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 30B7F1F452; Tue, 15 Jul 2025 13:31:01 +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 E71F813A68; Tue, 15 Jul 2025 13:31:00 +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 eCz4NhRYdmjFNwAAD6G6ig (envelope-from ); Tue, 15 Jul 2025 13:31:00 +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: f2f58e76-617f-11f0-a319-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586261; 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=k9Ov6pkpfp6346PXkACunqlof0M0Xfob950IWGq5/2o=; b=GZgJlpoCBy+rYCDCt4IbafXbgqpl7nET9XN3Z8IvzapYnhSQIfRN7P7X0t8ca0gaKPQjI8 FbQoTHshPOX6mKwlzmIesG3LbhPVl8eSDNCf6oCv17uUGZs3ghCQfRt6jbVWFTXcK7QjJc CYAoE4PphUscjM2FCT5hCV9SxiNLZao= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1752586261; 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=k9Ov6pkpfp6346PXkACunqlof0M0Xfob950IWGq5/2o=; b=GZgJlpoCBy+rYCDCt4IbafXbgqpl7nET9XN3Z8IvzapYnhSQIfRN7P7X0t8ca0gaKPQjI8 FbQoTHshPOX6mKwlzmIesG3LbhPVl8eSDNCf6oCv17uUGZs3ghCQfRt6jbVWFTXcK7QjJc CYAoE4PphUscjM2FCT5hCV9SxiNLZao= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, Juergen Gross , Jason Andryuk Subject: [MINI-OS PATCH v2 14/14] events: export bind_evtchn() Date: Tue, 15 Jul 2025 15:29:36 +0200 Message-ID: <20250715132936.2798-15-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250715132936.2798-1-jgross@suse.com> References: <20250715132936.2798-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)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:helo,amd.com:email] X-Spam-Flag: NO X-Spam-Level: X-Spam-Score: -2.80 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1752586983698116600 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