From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f73.google.com (mail-ed1-f73.google.com [209.85.208.73]) (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 3EF593630A7 for ; Tue, 23 Jun 2026 09:57:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782208660; cv=none; b=QYqC/3Y4BZnTrBBVWRIH3wHH4IEasffW396/ytb0IuoWYwS/8zwJwO8n6Aotzm9zqPAneGcBNP8zXZDee/9JRyM8fzkddJ57Is20OY4hZfPD0ANU6+OQ/LGdsN+uNcQUYcJIkQ6kniFrFHzs8leV8Auu7GFPz2QfPMwbWJeq9c4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782208660; c=relaxed/simple; bh=ZEi0jJAY1Xm47EaVD6sHk+vL3HcRgQbnUxBKNRyJbsQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=FkkO7PRNPfpotbh34qvDrX1hqy5l7n8fR2yDnsAJZbP0izJB/Uk1awdE33G9Mvkf00ETwVXc3UmvbVlQq5McRe4lMf5uHRGBA/0feDdYg8YHAaGny7I9XxdOb8Xo0pPIiBQIpkM93gFtAWmHzGKvPNLKP7WeomDZB+2/HB+1odc= 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=qxrzlYdm; arc=none smtp.client-ip=209.85.208.73 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="qxrzlYdm" Received: by mail-ed1-f73.google.com with SMTP id 4fb4d7f45d1cf-6960fb32b74so4573963a12.1 for ; Tue, 23 Jun 2026 02:57:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782208658; x=1782813458; 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=X6h9atGrmwYrKKQwd5mU+K5DW7kaXkRukWRnYNelZbM=; b=qxrzlYdmzcCQ176G4Bj4oUGWyaJJkDpetX1LsiGDkcvZCX336zKnIVy5dC7H+ugyoL P6t8S5x5OL/L6dY/FsXAJFJ6cMPiEKrouyDQN0V0TPzq3Yl4Gj0N0WbXEeJ+20qbskYz c5dyi/zibkai8/2qWT/RMa7JZzk97vKw112oY9ZYD/MtmZeZQVh+QmqYssGyzOHlpjyN /GvOKazHWBNjRH0HBPabgReK95AJa5QyAcLrr0R41SDk3fmqpqdjZoszQ4EYaO7El1my 8nulBduPiluPEzLGP5F3bPQv9b1Fqbr4yQWkzU3Brq3eM97f7ll/q3ujCIAp0cC7+GU8 liVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782208658; x=1782813458; 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=X6h9atGrmwYrKKQwd5mU+K5DW7kaXkRukWRnYNelZbM=; b=msAeQ9IYjVB31l2BlmS+FabQnSahYtKostRPTBWGz3tVCOERut7b80m4D/sqrsQaSN Yx/IPoK+Z6XQKFqS1xdDnY4qEfNemiKmvzWWwv+ilyx+GcBpwuDSGYFwY0XhX7he4t1n QmG+2pHld39JnMMnpatP64lQiUc0+beedCRFjJaBzjFKTG2ZycTBtfxT4VMeJSSXQDwW rVn2AOItIRwk9g5xbaBHyo7jLHcu+deuKZxBCIHEB0aU/Z+EIfVweLFwX3APQ1Zaihsr RnK0TcDrTcX5A0AhxA2xV3tkNAgGbDMy+MxqhScVlizBObQ9jEiewiigohiyQlwG68gc i+tw== X-Forwarded-Encrypted: i=1; AFNElJ/oqoXBOWuFftM9+A2GRH6YWfkayIqDQeF/ws1vaLm8aG2BXlrcdLJncw06qmLRBOEXoz5SGoTjcEiltXs=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+2OO37g8xJQe7OkI84rZIJLvX7js0T9P6IUaUcQWMO3HX+jCW ZXMkW45uUY2Kd3tH4H4XD5Fd30UhZeHgKH4+Hl1riNgx04+cJRSA1n9rL9US086mEFbTAOQyEj7 bGRFNtUkm0wof0wNLJg== X-Received: from edim4.prod.google.com ([2002:a50:cc04:0:b0:696:edc4:b307]) (user=tarunsahu job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:2710:b0:697:6b05:e801 with SMTP id 4fb4d7f45d1cf-697dbb38f5emr1011923a12.17.1782208657371; Tue, 23 Jun 2026 02:57:37 -0700 (PDT) Date: Tue, 23 Jun 2026 09:57:36 +0000 In-Reply-To: <178220761161.162773.13771896658073176.b4-review@b4> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260622225736.2961438-1-tarunsahu@google.com> <20260622225736.2961438-2-tarunsahu@google.com> <178220761161.162773.13771896658073176.b4-review@b4> Message-ID: <9huzmrwl37fz.fsf@tarunix.c.googlers.com> Subject: Re: [PATCH v4 1/2] kho: add KHOSER_COPY_TYPE(UN)SAFE for phys copy From: tarunsahu@google.com To: Mike Rapoport Cc: Pasha Tatashin , Mike Rapoport , Pratyush Yadav , Alexander Graf , Andrew Morton , linux-mm@kvack.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Mike Rapoport writes: > On Mon, 22 Jun 2026 22:57:35 +0000, Tarun Sahu wrote: >> Adding KHOSER_COPY_TYPESAFE and KHOSER_COPY_TYPEUNSAFE to copy one >> serializeable pointer to another. It basically allows copy of phys val >> of the serializeable pointer. > > Please update the commit message :) > >> >> >> diff --git a/include/linux/kho/abi/kexec_handover.h b/include/linux/kho/abi/kexec_handover.h >> index 5e2eb8519bda..c1b61d875dcc 100644 >> --- a/include/linux/kho/abi/kexec_handover.h >> +++ b/include/linux/kho/abi/kexec_handover.h >> @@ -139,6 +139,17 @@ >> (typeof((s).ptr))((s).phys ? phys_to_virt((s).phys) : NULL); \ >> }) >> >> +/* Copies one serializable pointer to another. */ >> +#define KHOSER_COPY_PTR(dest, src) \ >> + ({ \ >> + static_assert( \ >> + __builtin_types_compatible_p(typeof((dest).ptr), typeof((src).ptr)) || \ >> + __builtin_types_compatible_p(typeof((dest).ptr), void *) || \ >> + __builtin_types_compatible_p(typeof((src).ptr), void *), \ >> + "pointer type mismatch in KHOSER_COPY_PTR" \ >> + ); \ >> + (dest).phys = (src).phys; \ >> + }) > > I'd suggest declaring local variables for the pointers and verifying > their compatibility. E.g. > > ({ \ > typeof((dest).ptr) __dst; \ > typeof((src).ptr) __src; \ > static_assert( \ > __builtin_types_compatible_p(__dst, __src)) || \ > __builtin_types_compatible_p(__dst, void *) || \ > __builtin_types_compatible_p(__src, void *), \ > "pointer type mismatch in KHOSER_COPY_PTR" \ > ); \ > (dest).phys = (src).phys; \ > }) > > IMO it's easier to decipher this way. Okay, Will update in next revision. Thanks for reviewing. ~Tarun > > -- > Sincerely yours, > Mike.