Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1285276lqt; Tue, 19 Mar 2024 20:54:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUttESIDYQSA30tHy8NbUMG1W1Q5MROwFMbdzdxgE0etBvjSLAFY0uGFcZzq3UHq8Wo/vN/+oTGiV7cF4MTngtpKX5Ygw3hrqUPwNgJ5w== X-Google-Smtp-Source: AGHT+IHhHGTHZ9ajC3AO0xDbeCfnhF/VqrbFGDwqOcVlos6WqnoD4pQZVszQIx3zu+hq9pEhkrY/ X-Received: by 2002:a05:620a:847:b0:78a:1a97:f34 with SMTP id u7-20020a05620a084700b0078a1a970f34mr2494374qku.47.1710906877158; Tue, 19 Mar 2024 20:54:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710906877; cv=pass; d=google.com; s=arc-20160816; b=pKXd5+q6+L2yf1sNJBKze8NMAfmqnzyeQ1gsRydeS8GipqVHievHtq0vyfwm5O3R73 vd9wcbCwAnzJ8AgjXT12810TyTeUeGhypUenRG9RhFiCZl8TsnQQhCbuhCtVk8czc4OD acX1Jr3rZWBg/OpP+lPpZqRA+sZNrGWkqZhwBQ+w0d+0rX/GOiwn9uv0CL/peSP7po/y igOR80BaZwWjB5Jym14xa05iiRQM8axp3fNUHx49YrG/CaPRZyLTwnPGEm1CPBktAesK 0Pm3p1Mnzn8X1eKdVnkzeBgPlHHV0OCSK2ccJVf4Q8e9xyvfoWrAmOSZz1FjVeoUxj0Z LG7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=Vu0qllrSTaldILjVSOjGSnlA0IHzjykL6/AK/t7rtt8=; fh=YOMzn9NX6AZYO62tpzrVyo4BFA4s8PWVuDKJ/HYfyTQ=; b=RjvXh63Uw+M6jLe3unfkrKnh4Vuw77L/ZYxMnaCq6V6RXxiFCAjStaKWO7DX/FY56Y 81ID7tQVFelyFuS+9n/L33dhWzql9k2kHvwcfQ2N8D6wmsQoy6uI6R1mnqJxJWj9xM1h wgCwFlpHYeyVxnhQu1wdgeTifJwfXlrooj17xC1iQzvunfU3Pm2f8gERlaD72qDHJYj8 X/oIZj/autZGKcvWk3OnsxgC5bOwMBh83Om9+F8cdPK1Je5CgsL3P8Ixid2SBIz71sVg 05JPmHFkfHGzbIZFyyR/P732dy9geLj2mFRiOpHdGErTMF2ndvwVKpD06oC8rbsClOTY mzZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=i-love.sakura.ne.jp); spf=pass (google.com: domain of linux-kernel+bounces-108415-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108415-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m23-20020ae9f217000000b007886cc4988esi12759122qkg.161.2024.03.19.20.54.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 20:54:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108415-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=i-love.sakura.ne.jp); spf=pass (google.com: domain of linux-kernel+bounces-108415-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108415-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D6C0A1C218E7 for ; Wed, 20 Mar 2024 03:54:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F18411C92; Wed, 20 Mar 2024 03:54:31 +0000 (UTC) Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F22F11712 for ; Wed, 20 Mar 2024 03:54:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.181.97.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710906870; cv=none; b=dZXPFnUos1dPdSr7eoKIgtb/fkbwdMKa0cwZtIpijc4bqGpuAU8iC/MVmRPmFQJgt61jyLUGYJO1r/wrAPV0uA37Sf7TcId2nxXSFHhyikCM6e58sFstxnN8dla73zTeEa92xRUKsXaoJL5Qnwf5yq06gj8wnegVw2LDq4jpdDo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710906870; c=relaxed/simple; bh=XVB6+9HFSTGPkmI81vMP7oAx1uomsLy1PXz5e4m89X8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=I5paH4S65v5RBaJ4LSfjxVLZEpVVKTou11YVbOoERaHNGCBS8ZvIIP1No60iTvYq7bchw5Cz2buQKZCZ2S3BOSUPg5ng5tNzud9NnbKE9HqXuEgGyb0bynIy33OSwz5Y8dZ5kQ/54L1QTZz8K25BHp0n5i9I2IlREzn1QIKJv/k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=I-love.SAKURA.ne.jp; spf=pass smtp.mailfrom=I-love.SAKURA.ne.jp; arc=none smtp.client-ip=202.181.97.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=I-love.SAKURA.ne.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=I-love.SAKURA.ne.jp Received: from fsav413.sakura.ne.jp (fsav413.sakura.ne.jp [133.242.250.112]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 42K3sPLu062256; Wed, 20 Mar 2024 12:54:26 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav413.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav413.sakura.ne.jp); Wed, 20 Mar 2024 12:54:25 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav413.sakura.ne.jp) Received: from [192.168.1.6] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 42K3sPRp062253 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Wed, 20 Mar 2024 12:54:25 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: Date: Wed, 20 Mar 2024 12:54:25 +0900 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 3/3] x86: call instrumentation hooks from copy_mc.c Content-Language: en-US To: Alexander Potapenko , akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, kasan-dev@googlegroups.com, tglx@linutronix.de, x86@kernel.org, Linus Torvalds , Dmitry Vyukov , Marco Elver References: <20240319163656.2100766-1-glider@google.com> <20240319163656.2100766-3-glider@google.com> From: Tetsuo Handa In-Reply-To: <20240319163656.2100766-3-glider@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2024/03/20 1:36, Alexander Potapenko wrote: > @@ -61,10 +62,20 @@ unsigned long copy_mc_enhanced_fast_string(void *dst, const void *src, unsigned > */ > unsigned long __must_check copy_mc_to_kernel(void *dst, const void *src, unsigned len) > { > - if (copy_mc_fragile_enabled) > - return copy_mc_fragile(dst, src, len); > - if (static_cpu_has(X86_FEATURE_ERMS)) > - return copy_mc_enhanced_fast_string(dst, src, len); > + unsigned long ret; > + > + if (copy_mc_fragile_enabled) { > + instrument_memcpy_before(dst, src, len); I feel that instrument_memcpy_before() needs to be called *after* copy_mc_fragile() etc. , for we can't predict how many bytes will copy_mc_fragile() etc. actually copy. > + ret = copy_mc_fragile(dst, src, len); > + instrument_memcpy_after(dst, src, len, ret); > + return ret; > + }