Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6507652ybv; Wed, 12 Feb 2020 13:43:36 -0800 (PST) X-Google-Smtp-Source: APXvYqw16/fxYRz6HwW5LwmZfui7SyQz9e1MIeCS+iBwUpTTeaRJQUV8512lNM1IZweqQCQAQZpV X-Received: by 2002:a9d:7984:: with SMTP id h4mr11116133otm.297.1581543816329; Wed, 12 Feb 2020 13:43:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581543816; cv=none; d=google.com; s=arc-20160816; b=fruzG3HDuNRhCmdgnR9ZAfXjma5I7rKxajYrGxFINY558Jd6sn79zBT72t6J+Ku1IM 6CHznWL7ow9/lM+VJmwQYG/B04cZMC2bsIIavyhbq7XC1fLZGxxrE+jo+QKDfaqJktO8 dSG3BkEssJ5x9xMSumX0z0iVVI36+LgNWk8/4hu7COokRcNfffBn1cLO9zSeZGFC7cq9 k7Z5hBX8qBkPSA2e2pQy7CDD45ZA1g8RVyVTasfbMNZViYMQlE8o1qJrlw1xeavOs1/V BorpnygeRyQCkV8zAWEMoIoHzpdZyVjnJktRUAa1R/QjDwq4eT/NsA7gmSgvjgmdpQVk ka8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=7wbPz0Hjt9WwJEU290q8l1GZwfjZY4palN1aZv+WBAY=; b=ptm3ptXlCfJRJOGxiO8U7zJjEG680+lP0tsbrKt2OO1AcobCoZjDiQRs6eohOd8S/j YFU5cgGpE4dDGoib53jt44YQtvABcv7xe/gBPOYsV4Ky+/QBC8gVVZhQ0HWXubNGPk6H Nv2HiB6fp1APUavvtjqrChgEJcvFC4vDzS3pCXfB7mdOMDdtLFeqFc8RxxIh/uUImbEn Qt3qJM0clo7vPiav5X34EbLrSDKW61tlkE5AZP6Cb9RclFniKD94of6w5p3zcoIjtK7G AzaDm322IFHZlk4Sv6oXUCsohADJyoP1Auar+6LRXPg3mRyERbfDfHpL6HgH+wVBznZJ eMBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Do9dVLKH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r21si36277otd.135.2020.02.12.13.43.14; Wed, 12 Feb 2020 13:43:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Do9dVLKH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729103AbgBLVnC (ORCPT + 99 others); Wed, 12 Feb 2020 16:43:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:38612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727692AbgBLVnC (ORCPT ); Wed, 12 Feb 2020 16:43:02 -0500 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 74AD424685 for ; Wed, 12 Feb 2020 21:43:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581543781; bh=/5bgUjnXfKX/YnWj2CVZ6tzhbOUyGqaE9iljMsoLSUs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Do9dVLKHn+WmiWvVm5KO1giK1zzBjXFPv4K+0KaPaAU+ZFrJMbe3xrdYLXsMD33YT HT5tMqSNvg8QkYnRPtiJswNABvk53TkuOMS9PFoWqhT46b6TsoN0KZCIMozqIyV4K8 NqvZraXBlBMH2RxKnUB6a9FkfLoo3qPSZvOOkYtM= Received: by mail-wm1-f54.google.com with SMTP id s10so4008383wmh.3 for ; Wed, 12 Feb 2020 13:43:01 -0800 (PST) X-Gm-Message-State: APjAAAUgiHuW6NRh5Bqf+w3bXSRynjsQuXfJK0NblsTOr9gayHea1OzC HedqGcNdV+ZbZ1L4wZEHDbSQkgP9//wZvMjRqJeIEA== X-Received: by 2002:a05:600c:2207:: with SMTP id z7mr1155941wml.138.1581543779800; Wed, 12 Feb 2020 13:42:59 -0800 (PST) MIME-Version: 1.0 References: <20200211135256.24617-1-joro@8bytes.org> <20200211135256.24617-39-joro@8bytes.org> In-Reply-To: <20200211135256.24617-39-joro@8bytes.org> From: Andy Lutomirski Date: Wed, 12 Feb 2020 13:42:48 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 38/62] x86/sev-es: Handle instruction fetches from user-space To: Joerg Roedel Cc: X86 ML , "H. Peter Anvin" , Andy Lutomirski , Dave Hansen , Peter Zijlstra , Thomas Hellstrom , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , LKML , kvm list , Linux Virtualization , Joerg Roedel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 11, 2020 at 5:53 AM Joerg Roedel wrote: > > From: Joerg Roedel > > When a #VC exception is triggered by user-space the instruction > decoder needs to read the instruction bytes from user addresses. > Enhance es_fetch_insn_byte() to safely fetch kernel and user > instruction bytes. I realize that this is a somewhat arbitrary point in the series to complain about this, but: the kernel already has infrastructure to decode and fix up an instruction-based exception. See fixup_umip_exception(). Please refactor code so that you can share the same infrastructure rather than creating an entirely new thing. FWIW, the fixup_umip_exception() code seems to have much more robust segment handling than yours :) --Andy