From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16E87C433EF for ; Sat, 26 Mar 2022 08:28:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232108AbiCZI3p (ORCPT ); Sat, 26 Mar 2022 04:29:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230032AbiCZI3n (ORCPT ); Sat, 26 Mar 2022 04:29:43 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AD6925EC82 for ; Sat, 26 Mar 2022 01:28:05 -0700 (PDT) Received: from zn.tnic (p2e55dff8.dip0.t-ipconnect.de [46.85.223.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 103CE1EC05F1; Sat, 26 Mar 2022 09:28:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1648283280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=DaPzlO0lCBv97L6stIXP2Y4y6m9nV5ApnzETJlOBo8Y=; b=cMvGO5IKzFDcw+4zOxFzxDc6Xy0qZb7AQdAu1q9nNDc/GjFZBkOlSZ0ON+6l4zUhCUFYxK i0xpXNAu2DW2icNl3/rE6jwjdRAF0783VG3l9q1QZjl4SzeGU8NnysBPV7Pm5a/lxVU5wF VRsFSNFat/1LWtohLnrDUAMpkiPsGB8= Date: Sat, 26 Mar 2022 09:27:55 +0100 From: Borislav Petkov To: Dave Hansen Cc: Matthias Welwarsky , Dave Hansen , linux-kernel@vger.kernel.org, x86-ml Subject: Re: x86, possible bug in __memmove() alternatives patching Message-ID: References: <3422754.iIbC2pHGDl@linux-3513> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 25, 2022 at 09:45:24PM -0700, Dave Hansen wrote: > On 3/25/22 15:07, Borislav Petkov wrote: > > I know it's is probably a very rare case and Intel recommends having fast > > string ops enabled, hence the question: would this be considered a bug in the > > kernel that should be fixed? A potential fix could be to clear FSRM together > > with ERMS depending on IA32_MISC_ENABLE. > > I'd consider it a bug in the hypervisor, personally. ;) That's a given. > > But, we do try to make the kernel work even the face of funky > hypervisors that do things that never occur on real hardware. If a nice > patch to fix this up showed up, I'd definitely take a look. So, more to the point, it is about this chunk: /* * If fast string is not enabled in IA32_MISC_ENABLE for any reason, * clear the fast string and enhanced fast string CPU capabilities. */ if (c->x86 > 6 || (c->x86 == 6 && c->x86_model >= 0xd)) { rdmsrl(MSR_IA32_MISC_ENABLE, misc_enable); if (!(misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING)) { pr_info("Disabled fast string operations\n"); setup_clear_cpu_cap(X86_FEATURE_REP_GOOD); setup_clear_cpu_cap(X86_FEATURE_ERMS); } } we already check whether fast strings was disabled, regardless of HV or not. Question is, should we clear X86_FEATURE_FSRM there too. I wanna say yes. Or is it that, *if* MSR_IA32_MISC_ENABLE_FAST_STRING is clear, the FSRM CPUID bit was not set either so nothing to clear... Hmm? -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette