From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.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 9AFA3163 for ; Fri, 14 Nov 2025 00:46:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763081199; cv=none; b=FVs6wY+kaOs19xgDJV+o/OmlUOjKlX6Sv4Pv+FmlLuzccGQaXL8sulx7FSJage0wbXrYaEqd/Jb2VChuShDjkC12cRhuzBSK/Pd6QBQaUFZaHwLmePk8FnEu1xwfi72lYeWFwAfvqwIlT/J+1LSs/4KXDQSEFZQH8HBmoNkh0fU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763081199; c=relaxed/simple; bh=nmbKNMro6MZTXaDWQRL4nMdw/Xk8u52CGUuhUl6LVY0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=VpGzqiKO/5Q4JXl6m5aDNqTfOncW2mlNGW9WxVm9LGREaIYEvFYgvaFfUJ7QHy6Mro/jFvyfaWEB8KP5b3BGy9UGZ2g2nqfkPBC7cmlLHxSdM7K67kGuEP/imhRQbBAzgcsoZmnVhr5FlIZnh9Rrn5UZIcim4O1FuhgxJ+J9vBA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=24vVf21T; arc=none smtp.client-ip=209.85.216.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--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="24vVf21T" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-343725e6243so2561402a91.1 for ; Thu, 13 Nov 2025 16:46:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1763081197; x=1763685997; 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=uDj7CvwbWETtOWttFV8wxECqduFOZCdbeBiaXuQNabI=; b=24vVf21TNiVR7HpDAArvnegJYaoIhMxlERYuP5uqiRDZ+MLPGRTjfbIQmWdxWWcMy7 Ikn8+KUdJCS60KKONZsHycH4H2wDIeTPzFmtXhuXn1USWRHbkWLs13aXEj6iBRCzfhUg fv8JonjmyUwk2W7tappY+bdPHP6Yxav2ecaQUdvX0Ki9hcrAUVTAvmak+1TH/qltu+Wu q0MHOfIyxxHHy2ni6j1R9Tjltwy+QzEeCPjIFdYx62Z/PwjokDnI/W4EonEwhrG1GF7j m9EiUJM9KTG62UJkF5SQOVK2SzIO6/Y5dFpQzCzUX3Vo3dYAg92Lmhp2sszAVMFszlwQ Zrvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763081197; x=1763685997; 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=uDj7CvwbWETtOWttFV8wxECqduFOZCdbeBiaXuQNabI=; b=w4UCDcXVfPQzlMrCltDQMJM4pYhisjT/eUMWnjvU3BPnELivJF6JvnNgw+djBylPcD LYTaLwg0tFmeJSmNnGIXV2aQzQcZ8BXxOqZEbxNTUZCvo86Tv36eW15e48+rbOIajAsB ZBP5IO/SYjAhsz9UdopujsF0Z3hZuQLWcmGu0W9JfMc+wai+Fy7gQuWit9APQoMAvK2d Ve9IynrE6ziMA9fGHAt6lirym4CSuRPwZdd2FxDDkWuBle5xCOuRykAibVocWl4LCWdM pAf6NZtY9fYmL9hu6OM19yk8jgW6BA1iFDEhyeYXbpMu0DuOLWMwyBLndJWolw5owjuW 3n6w== X-Forwarded-Encrypted: i=1; AJvYcCV0LLiDwUctHP8gNLl/p52hDXLRzos5Q0mQE1qXQUHLMFuChHsN74RkgzYy6U8dp/498DYC9Z1pXj9C5Zg=@vger.kernel.org X-Gm-Message-State: AOJu0YwpgFWxtyHto61o0wMT7vj6RgndRfNht5qxefwsXKKF2oJWQFy4 o7tLH+fzArivjDrxbr4rckZyVwCzDlwKX4UUnAhyq1oTkXvYZhNJ9kOiwnLUdjvJ1MOZ7Xd7YAV B8XMNjA== X-Google-Smtp-Source: AGHT+IFvWxC5jOH/W7eS+nx6SQqbPD99U8lJhPUWnbz/npn1mBEdcUauKA+rus1zvm7yDcrcnsd0aUY+nko= X-Received: from pjbpv11.prod.google.com ([2002:a17:90b:3c8b:b0:33b:e0b5:6112]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:548c:b0:340:29a3:800f with SMTP id 98e67ed59e1d1-343eacb9cdfmr6087762a91.15.1763081196994; Thu, 13 Nov 2025 16:46:36 -0800 (PST) Date: Thu, 13 Nov 2025 16:46:03 -0800 In-Reply-To: <20251106210206.221558-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251106210206.221558-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.rc1.455.g30608eb744-goog Message-ID: <176305665095.1602845.9274238002903506152.b4-ty@google.com> Subject: Re: [PATCH] KVM: x86: Use "checked" versions of get_user() and put_user() From: Sean Christopherson To: Sean Christopherson , Vitaly Kuznetsov , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds , Borislav Petkov Content-Type: text/plain; charset="utf-8" On Thu, 06 Nov 2025 13:02:06 -0800, Sean Christopherson wrote: > Use the normal, checked versions for get_user() and put_user() instead of > the double-underscore versions that omit range checks, as the checked > versions are actually measurably faster on modern CPUs (12%+ on Intel, > 25%+ on AMD). > > The performance hit on the unchecked versions is almost entirely due to > the added LFENCE on CPUs where LFENCE is serializing (which is effectively > all modern CPUs), which was added by commit 304ec1b05031 ("x86/uaccess: > Use __uaccess_begin_nospec() and uaccess_try_nospec"). The small > optimizations done by commit b19b74bc99b1 ("x86/mm: Rework address range > check in get_user() and put_user()") likely shave a few cycles off, but > the bulk of the extra latency comes from the LFENCE. > > [...] Applied to kvm-x86 misc, with a call out in the changelog that the Hyper-V path isn't performance sensitive, and that the motiviation is consistency and the purging of __{get,put}_user(). [1/1] KVM: x86: Use "checked" versions of get_user() and put_user() https://github.com/kvm-x86/linux/commit/d1bc00483759 -- https://github.com/kvm-x86/linux/tree/next