From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f74.google.com (mail-ed1-f74.google.com [209.85.208.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A6C634404A for ; Tue, 23 Jun 2026 11:12:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782213180; cv=none; b=iFUQoOR4obbQMg2BxWFkrIXmRbGqFWXJ2dDpg5EkI8glokEDcFdypVMXpUM/tYr1cBzCvRhC/Eq0FXUDeDMALaW+9Pxyk37NHdx1CANfSnGjVyVOvJ67z/WHjl1fQG4c6kYyjhnUn1juI1dZ5wUODQSXh+iDweKE71hpSXBm13w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782213180; c=relaxed/simple; bh=PgwcVBhqUhz0BM948YmtvUrWhdVoOHcQWfZ6j50Uz6U=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=E+lrdomOcL8Wz+dSj9YvQ7Ten+0dhbvWWjf0k/M/7NckORrNaoAwVPKXhjohDsSupEPfJenL/o5R1GP5xKIfXEBu6fLVUZm4e0oFclMhqzfO7GlTYYygN/cpl4tv0IR+8F0Tmrnxw/mfWQJoJ5UrL1/8ev0H9Du1xNk6WM4XjmA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--tarunsahu.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=FR5NdwVD; arc=none smtp.client-ip=209.85.208.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--tarunsahu.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FR5NdwVD" Received: by mail-ed1-f74.google.com with SMTP id 4fb4d7f45d1cf-695796f97aeso5721024a12.0 for ; Tue, 23 Jun 2026 04:12:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782213178; x=1782817978; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=GlrS6JHBNQ5+edYZVjnAg+a7odL1f1I5wF5DpzXWwZg=; b=FR5NdwVDJIJkAIDmzUKT+qsJEGcULcm4oKNCGBnxSbIj+4pHa0xE9c6/UoZ00xkjgc azKunkR1QjLJqvuaOWM4eca/xmvwd7OAxc9nVebbfolQE3xyX/2DY0ZdK+wSauwkdJR3 OgzoxGuthECR+ZpmE8GPM+p4QNrBZPRdLt7EQtLRNpnMVXImvO/55SC5yrQOWie0jQMW yLifqndeRy5pN9oPKttWcjF3PyPR6d7zwkLov1UzSNhslDdvxoH1nKEkKrC1DoL8gbuk xC4XGA0uFFSOUcivmgb/Jcq9QHbNRdNY3SgAsTN17bHqXMX7StVfRT+WQ5mIBtl9+3sK h9UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782213178; x=1782817978; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GlrS6JHBNQ5+edYZVjnAg+a7odL1f1I5wF5DpzXWwZg=; b=ld7fRPtOHBIc2yqx4HHX9bBn81prASE/ysJpGNy343IZ2M2FKmEmoO+LqTvIjH6XrZ 6du6+M4kMuPt3EiDwIvfc6u2ZB7FywfctyBqVL3Tt+aYoi4TSGR3Kr/u6/Tkqwspoh8j G9Bdf4MH4v+SCaAPqZVzN9xr3DEC5rJ3QZkbvbgMp3ECHRSRfBcNGi5hTUAaUqEfvzN3 E5SeqtuWfst24q806wCh9zbgMidJ8Yr0m2GnnWUC+w6TGbGz4eIqLSxtgffJXrwV+Bz7 4S1/nBi4pLfjQ+8Y3wZUACPGc2Yb0xixpD7xyrslZ4zJEw3ejXnUpvuYnJvbHg4sBIrK JdEw== X-Forwarded-Encrypted: i=1; AFNElJ/fysBmnfjNXk5zp6SVdll0X7muB+vF49NM+G/iKn50qeiZ740C4G6fhkIMz7orPyae3mbg2rNZE3zw0g8=@vger.kernel.org X-Gm-Message-State: AOJu0Yyg7726aJA6ykVC/uVn6EBAXY5+B9mlFLmRiKCXPixICBeuR579 VEffvqfOMrc6Ga/J8RlxP/XNwqbB9Zd2UUeDH9Txqw+XvyPqJfOohZY0LtJ1eJ86vvewgWEQw8f 89YevYmGN3MJRa1rSDg== X-Received: from edj17.prod.google.com ([2002:a05:6402:3251:b0:697:967b:20e9]) (user=tarunsahu job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:144d:b0:697:4e2c:c8ce with SMTP id 4fb4d7f45d1cf-697dbb3b56amr1244442a12.15.1782213177187; Tue, 23 Jun 2026 04:12:57 -0700 (PDT) Date: Tue, 23 Jun 2026 11:12:56 +0000 In-Reply-To: <20260623105201.3724592-4-tarunsahu@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260623105201.3724592-1-tarunsahu@google.com> <20260623105201.3724592-4-tarunsahu@google.com> Message-ID: <9huz7bnpo6h3.fsf@tarunix.c.googlers.com> Subject: Re: [PATCH v5 3/3] luo: Update serialized data to use KHOSER_PTR From: tarunsahu@google.com To: Mike Rapoport , Pasha Tatashin , Pratyush Yadav , Andrew Morton , Alexander Graf Cc: kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Tarun Sahu writes: > Convert raw serialized_data to KHO serializeable pointer (KHOSER_PTR). > This series also takes care of resolving the bug with memfd of using > phys_to_virt before checking the args->serialized_data value. This no longer needs the memfd_luo fix information. ~Tarun > > Signed-off-by: Tarun Sahu > Acked-by: Mike Rapoport (Microsoft) > --- > include/linux/kho/abi/luo.h | 5 +++-- > include/linux/liveupdate.h | 4 ++-- > kernel/liveupdate/luo_file.c | 24 ++++++++++++------------ > mm/memfd_luo.c | 20 +++++++++++--------- > 4 files changed, 28 insertions(+), 25 deletions(-) > > diff --git a/include/linux/kho/abi/luo.h b/include/linux/kho/abi/luo.h > index 288076de6d4a..d5b3b1c0fec1 100644 > --- a/include/linux/kho/abi/luo.h > +++ b/include/linux/kho/abi/luo.h > @@ -59,6 +59,7 @@ > > #include > #include > +#include > #include > > /* > @@ -89,14 +90,14 @@ struct luo_ser { > /** > * struct luo_file_ser - Represents the serialized preserves files. > * @compatible: File handler compatible string. > - * @data: Private data > + * @serialized_data: The serialized pointer union for this file > * @token: User provided token for this file > * > * If this structure is modified, `LUO_ABI_COMPATIBLE` must be updated. > */ > struct luo_file_ser { > char compatible[LIVEUPDATE_HNDL_COMPAT_LENGTH]; > - u64 data; > + DECLARE_KHOSER_PTR(serialized_data, void *); > u64 token; > } __packed; > > diff --git a/include/linux/liveupdate.h b/include/linux/liveupdate.h > index 88722e5caf02..480d638b7d18 100644 > --- a/include/linux/liveupdate.h > +++ b/include/linux/liveupdate.h > @@ -33,7 +33,7 @@ struct file; > * @file: The file object. For retrieve: [OUT] The callback sets > * this to the new file. For other ops: [IN] The caller sets > * this to the file being operated on. > - * @serialized_data: The opaque u64 handle, preserve/prepare/freeze may update > + * @serialized_data: The serialized pointer union, preserve/prepare/freeze may update > * this field. > * @private_data: Private data for the file used to hold runtime state that > * is not preserved. Set by the handler's .preserve() > @@ -47,7 +47,7 @@ struct liveupdate_file_op_args { > struct liveupdate_file_handler *handler; > int retrieve_status; > struct file *file; > - u64 serialized_data; > + DECLARE_KHOSER_PTR(serialized_data, void *); > void *private_data; > }; > > diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c > index c39f96961a85..aecf19033f95 100644 > --- a/kernel/liveupdate/luo_file.c > +++ b/kernel/liveupdate/luo_file.c > @@ -125,7 +125,7 @@ static DEFINE_XARRAY(luo_preserved_files); > * @file: Pointer to the kernel's &struct file that is being preserved. > * This is NULL in the new kernel until the file is successfully > * retrieved. > - * @serialized_data: The opaque u64 handle to the serialized state of the file. > + * @serialized_data: The serialized pointer union to the serialized state of the file. > * This handle is passed back to the handler's .freeze(), > * .retrieve(), and .finish() callbacks, allowing it to track > * and update its serialized state across phases. > @@ -161,7 +161,7 @@ static DEFINE_XARRAY(luo_preserved_files); > struct luo_file { > struct liveupdate_file_handler *fh; > struct file *file; > - u64 serialized_data; > + DECLARE_KHOSER_PTR(serialized_data, void *); > void *private_data; > int retrieve_status; > struct mutex mutex; > @@ -289,7 +289,7 @@ int luo_preserve_file(struct luo_file_set *file_set, u64 token, int fd) > if (err) > goto err_kfree; > > - luo_file->serialized_data = args.serialized_data; > + KHOSER_COPY_PTR(luo_file->serialized_data, args.serialized_data); > luo_file->private_data = args.private_data; > list_add_tail(&luo_file->list, &file_set->files_list); > file_set->count++; > @@ -342,7 +342,7 @@ void luo_file_unpreserve_files(struct luo_file_set *file_set) > > args.handler = luo_file->fh; > args.file = luo_file->file; > - args.serialized_data = luo_file->serialized_data; > + KHOSER_COPY_PTR(args.serialized_data, luo_file->serialized_data); > args.private_data = luo_file->private_data; > luo_file->fh->ops->unpreserve(&args); > luo_flb_file_unpreserve(luo_file->fh); > @@ -375,12 +375,12 @@ static int luo_file_freeze_one(struct luo_file_set *file_set, > > args.handler = luo_file->fh; > args.file = luo_file->file; > - args.serialized_data = luo_file->serialized_data; > + KHOSER_COPY_PTR(args.serialized_data, luo_file->serialized_data); > args.private_data = luo_file->private_data; > > err = luo_file->fh->ops->freeze(&args); > if (!err) > - luo_file->serialized_data = args.serialized_data; > + KHOSER_COPY_PTR(luo_file->serialized_data, args.serialized_data); > } > > return err; > @@ -396,7 +396,7 @@ static void luo_file_unfreeze_one(struct luo_file_set *file_set, > > args.handler = luo_file->fh; > args.file = luo_file->file; > - args.serialized_data = luo_file->serialized_data; > + KHOSER_COPY_PTR(args.serialized_data, luo_file->serialized_data); > args.private_data = luo_file->private_data; > > luo_file->fh->ops->unfreeze(&args); > @@ -483,7 +483,7 @@ int luo_file_freeze(struct luo_file_set *file_set, > > strscpy(file_ser->compatible, luo_file->fh->compatible, > sizeof(file_ser->compatible)); > - file_ser->data = luo_file->serialized_data; > + KHOSER_COPY_PTR(file_ser->serialized_data, luo_file->serialized_data); > file_ser->token = luo_file->token; > } > > @@ -587,7 +587,7 @@ int luo_retrieve_file(struct luo_file_set *file_set, u64 token, > } > > args.handler = luo_file->fh; > - args.serialized_data = luo_file->serialized_data; > + KHOSER_COPY_PTR(args.serialized_data, luo_file->serialized_data); > err = luo_file->fh->ops->retrieve(&args); > if (err) { > /* Keep the error code for later use. */ > @@ -621,7 +621,7 @@ static int luo_file_can_finish_one(struct luo_file_set *file_set, > > args.handler = luo_file->fh; > args.file = luo_file->file; > - args.serialized_data = luo_file->serialized_data; > + KHOSER_COPY_PTR(args.serialized_data, luo_file->serialized_data); > args.retrieve_status = luo_file->retrieve_status; > can_finish = luo_file->fh->ops->can_finish(&args); > } > @@ -638,7 +638,7 @@ static void luo_file_finish_one(struct luo_file_set *file_set, > > args.handler = luo_file->fh; > args.file = luo_file->file; > - args.serialized_data = luo_file->serialized_data; > + KHOSER_COPY_PTR(args.serialized_data, luo_file->serialized_data); > args.retrieve_status = luo_file->retrieve_status; > > luo_file->fh->ops->finish(&args); > @@ -748,7 +748,7 @@ static int luo_file_deserialize_one(struct luo_file_set *file_set, > > luo_file->fh = fh; > luo_file->file = NULL; > - luo_file->serialized_data = ser->data; > + KHOSER_COPY_PTR(luo_file->serialized_data, ser->serialized_data); > luo_file->token = ser->token; > mutex_init(&luo_file->mutex); > list_add_tail(&luo_file->list, &file_set->files_list); > diff --git a/mm/memfd_luo.c b/mm/memfd_luo.c > index 10f3983b0060..852b61678229 100644 > --- a/mm/memfd_luo.c > +++ b/mm/memfd_luo.c > @@ -257,6 +257,7 @@ static void memfd_luo_unpreserve_folios(struct kho_vmalloc *kho_vmalloc, > > static int memfd_luo_preserve(struct liveupdate_file_op_args *args) > { > + DECLARE_KHOSER_PTR(sd, struct memfd_luo_ser *); > struct inode *inode = file_inode(args->file); > struct memfd_luo_folio_ser *folios_ser; > struct memfd_luo_ser *ser; > @@ -309,7 +310,8 @@ static int memfd_luo_preserve(struct liveupdate_file_op_args *args) > inode_unlock(inode); > > args->private_data = folios_ser; > - args->serialized_data = virt_to_phys(ser); > + KHOSER_STORE_PTR(sd, ser); > + KHOSER_COPY_PTR(args->serialized_data, sd); > > return 0; > > @@ -325,11 +327,10 @@ static int memfd_luo_freeze(struct liveupdate_file_op_args *args) > { > struct memfd_luo_ser *ser; > > - if (WARN_ON_ONCE(!args->serialized_data)) > + ser = KHOSER_LOAD_PTR(args->serialized_data); > + if (WARN_ON_ONCE(!ser)) > return -EINVAL; > > - ser = phys_to_virt(args->serialized_data); > - > /* > * The pos might have changed since prepare. Everything else stays the > * same. > @@ -344,14 +345,13 @@ static void memfd_luo_unpreserve(struct liveupdate_file_op_args *args) > struct inode *inode = file_inode(args->file); > struct memfd_luo_ser *ser; > > - if (WARN_ON_ONCE(!args->serialized_data)) > + ser = KHOSER_LOAD_PTR(args->serialized_data); > + if (WARN_ON_ONCE(!ser)) > return; > > inode_lock(inode); > shmem_freeze(inode, false); > > - ser = phys_to_virt(args->serialized_data); > - > memfd_luo_unpreserve_folios(&ser->folios, args->private_data, > ser->nr_folios); > > @@ -397,7 +397,8 @@ static void memfd_luo_finish(struct liveupdate_file_op_args *args) > if (args->retrieve_status) > return; > > - if (!args->serialized_data) > + ser = KHOSER_LOAD_PTR(args->serialized_data); > + if (!ser) > return; > > ser = phys_to_virt(args->serialized_data); > @@ -523,7 +524,8 @@ static int memfd_luo_retrieve(struct liveupdate_file_op_args *args) > struct file *file; > int err; > > - if (!args->serialized_data) > + ser = KHOSER_LOAD_PTR(args->serialized_data); > + if (!ser) > return -EINVAL; > > ser = phys_to_virt(args->serialized_data); > -- > 2.55.0.rc0.786.g65d90a0328-goog