Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5014299rwd; Sun, 4 Jun 2023 18:42:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4xYFBasOzpG9H1I01ReUEIOPiAwDOUFt418sOwcWkyq7oDTiP2zdHWzgokF7ps+AvWz7e0 X-Received: by 2002:ac8:7dcc:0:b0:3f9:a618:f9bd with SMTP id c12-20020ac87dcc000000b003f9a618f9bdmr1100954qte.25.1685929375624; Sun, 04 Jun 2023 18:42:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685929375; cv=none; d=google.com; s=arc-20160816; b=r+n9Rq74b7ad3/NYn3tH1TirTb2phMGeOmbFe6z27pL9a10ArZ3/cruYAdz+oLtf5E 7Dtu2wJtxcTdj2FLuOI+7mJdYTjIUQ0oUQENEQAaMq3FLxtpp/RZlZtEcr3JRdyeMADu sNsa0/4gklogzSFsOHR4vCjJxWaptXTnWnS9SCDltrJzBs5k+SgRjz9Zc8AQF7tXkQJk mkPtqp17UaNjLzW+Tc+fATMtJBBMKLE5PdXmtgwT3h5egKbaqSXl/VHsuY8BGym02yOw T5o3HZDTkq7F2oalz7E4/Cf9Vi6qUGhQzULUyDLNhMi9lqZRwW+qBdpvHBm0J7SkYlWj UAew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=KdhXzRBGvpa7XHvwhL40dKeWlOr0InxtIYiwr5BFcKs=; b=xeEenFukRbH3P02QfXxjNLp6JDGLLwQj8Lv0GJQ3Wc4JXLrEQTCkD9Ar12wxVe+rsx k/b59LVvt0EL56vKDj024yEvFNUyFVN2rBc7jivmr4C98pG/kQxCehbVnTh5hDjxhqtR 4LZBa/PJZbiJERcmPXaRwTNk7didf43hbDj0fh7Idr+Uiwz3lQWp7YJoliJWuLZmej19 cbFx6vNYJj0WsP2NwLdzvMyqhL4K8h40ybAzbRE2b0yFBWeQvrYc4UU0dN2QefHSOZt1 2DQIOMa4zFqNSkAQ4mIIA9LC9AaWrxcd5hVlxExuaye29afTTM+R2A7ZYa9aBs2voqUW tSZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iUnCi5EP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 24-20020a631258000000b0051985ec117bsi4790312pgs.69.2023.06.04.18.42.41; Sun, 04 Jun 2023 18:42:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iUnCi5EP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230378AbjFEBjl (ORCPT + 99 others); Sun, 4 Jun 2023 21:39:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229670AbjFEBjj (ORCPT ); Sun, 4 Jun 2023 21:39:39 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6F63A1; Sun, 4 Jun 2023 18:39:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685929177; x=1717465177; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=FvdPokw1eJQlrk8ZKjLQCsp3vJvdFbHxCoJqlQurJkE=; b=iUnCi5EPoEI9ldYRvY4lcRJUo80ibB2UDmsrl8eqfcHBCeL4ibWefiax /w01Onqb5OErGGiN105vNGPjObpMjRksaFj2x/3yXFNT+xx0SkpIONUsJ RROkE5wN8OjiKtPFKPZsWAYKWcRAzgpJvN00UISOn67NUMUNkvx+LSGhE fjqcR+N5eEub6/J1KYZjWAjPc4Du5FUX+G8390WrrjCJSYzrOjeHj012v gKLq9Usi0WcMFlp9De6QIHQ2u5YbVIezWEubk9Bzz3+52ue1Eh3dEJ5TV TwhBM/0BZUKGp+ah7F5B2yhiF1zA8gox++m/nEGAEHqNrfbwGj0XKIBS6 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10731"; a="356268227" X-IronPort-AV: E=Sophos;i="6.00,217,1681196400"; d="scan'208";a="356268227" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2023 18:39:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10731"; a="708490085" X-IronPort-AV: E=Sophos;i="6.00,217,1681196400"; d="scan'208";a="708490085" Received: from binbinwu-mobl.ccr.corp.intel.com (HELO [10.238.9.17]) ([10.238.9.17]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2023 18:39:34 -0700 Message-ID: <08cf5a8a-7937-c033-06e7-85fe42758eaa@linux.intel.com> Date: Mon, 5 Jun 2023 09:39:32 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [PATCH v1 0/6] LASS KVM virtualization support To: Zeng Guang Cc: Paolo Bonzini , Sean Christopherson , Thomas Gleixner , Ingo Molnar , Dave Hansen , H Peter Anvin , Borislav Petkov , kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org References: <20230601142309.6307-1-guang.zeng@intel.com> From: Binbin Wu In-Reply-To: <20230601142309.6307-1-guang.zeng@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/1/2023 10:23 PM, Zeng Guang wrote: > Subject: > [PATCH v1 0/6] LASS KVM virtualization support > From: > Zeng Guang > Date: > 6/1/2023, 10:23 PM > > To: > Paolo Bonzini , Sean Christopherson > , Thomas Gleixner , Ingo Molnar > , Borislav Petkov , Dave Hansen > , H Peter Anvin , > kvm@vger.kernel.org > CC: > x86@kernel.org, linux-kernel@vger.kernel.org, Zeng Guang > > > > Linear Address Space Separation (LASS)[1] is an independent mechanism > that enforces the mode-based protections on any access to a linear > address. > > Based on a linear-address organization, the 64-bit canonical linear > address space is partitioned into two halves: all linear addresses > whose most significant bit is 0 are user space addresses, while linear > addresses whose most significant bit is 1 are supervisor space address. > > LASS aims to prevent any attempt to probe supervisor space addresses by > user mode, and likewise stop any attempt to access (if SMAP enabled) or > execute user space addresses from supervisor mode. > > When platform has LASS capability, KVM requires to expose this feature > to guest VM enumerated by CPUID.(EAX=07H.ECX=1):EAX.LASS[bit 6], and > allow guest to enable it via CR4.LASS[bit 27] on demand. For instruction > executed in the guest directly, hardware will perform the check. But KVM > also needs to behave same as hardware to apply LASS to kinds of guest > memory accesses when emulating privileged instructions by software. Not just privileged instructions, e.g. MMIO access instructions. > > KVM will take following LASS voilations check on emulation path. /s/voilations/violations > User-mode access to supervisor space address: > LA[bit 63] && (CPL == 3) > Supervisor-mode access to user space address: > Instruction fetch: !LA[bit 63] && (CPL < 3) > Data access: !LA[bit 63] && (CR4.SMAP==1) && ((RFLAGS.AC == 0 && > CPL < 3) || Implicit supervisor access) > > This patch series provide a LASS KVM solution. > > We tested the basic function of LASS virtualization including LASS > enumeration and enabling in non-root and nested environment. As KVM > unittest framework is not compatible to LASS rule, we use kernel module > and application test to emulate LASS violation instead. With KVM forced > emulation mechanism, we also verified the LASS functionality on some > emulation path with instruction fetch and data access to have same > behavior as hardware. > > [1] Intel ISEhttps://cdrdv2.intel.com/v1/dl/getContent/671368 > Chapter Linear Address Space Separation (LASS) > > ------------------------------------------------------ > > v0->v1 > 1. Adapt to new __linearize() API > 2. Function refactor of vmx_check_lass() > 3. Refine commit message to be more precise > 4. Drop LASS kvm cap detection depending > on hardware capability > > > Binbin Wu (1): > KVM: x86: Consolidate flags for __linearize() > > Zeng Guang (5): > KVM: x86: Virtualize CR4.LASS > KVM: VMX: Add new ops in kvm_x86_ops for LASS violation check > KVM: x86: Add emulator helper for LASS violation check > KVM: x86: LASS protection on KVM emulation > KVM: x86: Advertise LASS CPUID to user space > > arch/x86/include/asm/kvm-x86-ops.h | 3 +- > arch/x86/include/asm/kvm_host.h | 4 ++- > arch/x86/kvm/cpuid.c | 5 ++- > arch/x86/kvm/emulate.c | 47 +++++++++++++++++++++++----- > arch/x86/kvm/kvm_emulate.h | 6 ++++ > arch/x86/kvm/vmx/nested.c | 3 ++ > arch/x86/kvm/vmx/sgx.c | 4 +++ > arch/x86/kvm/vmx/vmx.c | 50 ++++++++++++++++++++++++++++++ > arch/x86/kvm/vmx/vmx.h | 2 ++ > arch/x86/kvm/x86.c | 12 +++++++ > arch/x86/kvm/x86.h | 2 ++ > 11 files changed, 126 insertions(+), 12 deletions(-) > > -- 2.27.0