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 B99D0EE14A9 for ; Wed, 6 Sep 2023 23:01:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244736AbjIFXBW (ORCPT ); Wed, 6 Sep 2023 19:01:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231475AbjIFXBV (ORCPT ); Wed, 6 Sep 2023 19:01:21 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDFC019B5 for ; Wed, 6 Sep 2023 16:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694041277; x=1725577277; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=awpKATS8jUdcDj7eQHRvrOutVUUwskNG8zGevD2cdnE=; b=d9oUVRCDnv7iV3cDPVhldrvUYyKH/l7d3JaWRmzyh0gqBuGQL51+TwIQ PTbecqiIaByiAHA4FOG8WaDnDT1Whow3c6PFjwMTFu3BBxHojc98TxvuL EgfLZvtzZqGvHrbgHZOcBDb0I5WS5WqvyjAMPtoEGv2YZs6E2sxsLyF+S N71Vhm66++PSLjmtguOzkPBh0ohVCMLknQtDCUpePuaWQ0T0NBs8SetGq iskunEh7SAbWFikpca2+R33aE4gRJPYalw6iXrWZuUeLpFrjoT9oCx4Ne cMRtAEN9gfe3kf42Ywi8kw5l9M9YsWmu8Hnrw47GvDh3fiz+1FDlDZqrU A==; X-IronPort-AV: E=McAfee;i="6600,9927,10825"; a="367427703" X-IronPort-AV: E=Sophos;i="6.02,233,1688454000"; d="scan'208";a="367427703" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2023 16:01:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10825"; a="915463005" X-IronPort-AV: E=Sophos;i="6.02,233,1688454000"; d="scan'208";a="915463005" Received: from lmgabald-mobl2.amr.corp.intel.com (HELO [10.212.242.149]) ([10.212.242.149]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2023 16:01:16 -0700 Message-ID: Date: Wed, 6 Sep 2023 16:01:16 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH] x86/sev-es: Do not use copy_from_kernel_nofault in early #VC handler Content-Language: en-US To: Adam Dunlap , linux-kernel@vger.kernel.org, x86@kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Tom Lendacky , David Hildenbrand , Mike Rapoport , "Kirill A. Shutemov" , Nikunj A Dadhania , Dionna Glaze , "Peter Zijlstra (Intel)" , Joerg Roedel , Jacob Xu References: <20230906224541.2778523-1-acdunlap@google.com> From: Dave Hansen In-Reply-To: <20230906224541.2778523-1-acdunlap@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/6/23 15:45, Adam Dunlap wrote: > static int vc_fetch_insn_kernel(struct es_em_ctxt *ctxt, > - unsigned char *buffer) > + unsigned char *buffer, bool is_early) > { > - return copy_from_kernel_nofault(buffer, (unsigned char *)ctxt->regs->ip, MAX_INSN_SIZE); > + if (is_early) { > + memcpy(buffer, (unsigned char *)ctxt->regs->ip, MAX_INSN_SIZE); > + return 0; > + } else { > + return copy_from_kernel_nofault(buffer, (unsigned char *)ctxt->regs->ip, > + MAX_INSN_SIZE); > + } > } This isn't the normal way we do these kinds of things. If we go with this solution, they next guy who tries copy_from_kernel_nofault() will hit the same issue, and start plumbing their own 'is_early' through _their_ little chunk of arch/x86. Usually, we'll add some gunk in arch/x86/boot/compressed/misc.h to override the troublesome implementation. In this case, it would make a lot of sense to somehow avoid touching boot_cpu_data.x86_virt_bits in the first place.