Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp131424imm; Wed, 22 Aug 2018 01:10:13 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzjOi12zxyCejCoeDRD+vIhDonjtSBCevUieXbltSdU5hjxjVm99EvxL86urQzdoJSmgiuI X-Received: by 2002:a65:4b87:: with SMTP id t7-v6mr49982069pgq.391.1534925413518; Wed, 22 Aug 2018 01:10:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534925413; cv=none; d=google.com; s=arc-20160816; b=FZXMWdeBTKQtRXrDUBjJygyCuPaRsbVLAK01mE7JIPk60r2ILICJ/XGJ7IbnS1BP66 BVYCh0f0RtZeuftlL5MSxuf52ivWC7BnjAcQPuqYHy6GG6kqr0Ibl7SP1i9set+4xya5 +BsNLd+IftcgxQhHozJQy3VzfdxHiDlSdpCBP4405guxwZ60NDw8LWSxqe+r/TzvJRya BCky9aLpkRyLK1iPT0aXCQhaAc/AV0AU7o5lTAwWMl5BF5/9RkfwLr+DOjR1jXPsBhXF OpuEz8nH42O1blYNMeHlejXOyL7RQMtsSykl6KBjZ0+ZATbvx4Izmgm3uyoB4mnDBrs0 adPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=pnPy0ZwpuknnPswmZKUDjTHtezqeD3EUbzxIj+Ggi/I=; b=Vc5g/cT1pkRekUKm96FGKGRgt84Igtk1qpEvr0yk8AQDQCYhKMmOMWJlAO505K9YgI z7c0O+TDj8g84xrc1VFXtd5hKmTmEVnTCc7jleZvu8uPc4MZchgcGOglJ75BlqQRIwNC 5o6MtVrGW12Z//CokMjcnpoZPMQkUCo0dqvf7YPlAo4denqoiVpSXHHJdXGtPkhBaQhf n+2CDeOw4tnj+3AfR9p+IRi8zCjpgCU+fK1AXtEEwO3JePJNgROzNoUZaQWMjGMVdm8/ vqUTAXueFj0HNc6nojVexDaFlDZz14tZGZfI815gD+IedvxgJwo8jUavmmx4eLp6vtW6 /VLg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b8-v6si993405plx.110.2018.08.22.01.09.58; Wed, 22 Aug 2018 01:10:13 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728228AbeHVLN3 (ORCPT + 99 others); Wed, 22 Aug 2018 07:13:29 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:60990 "EHLO mail.valinux.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726736AbeHVLN3 (ORCPT ); Wed, 22 Aug 2018 07:13:29 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.valinux.co.jp (Postfix) with ESMTP id BAB36B3A36; Wed, 22 Aug 2018 16:49:45 +0900 (JST) X-Virus-Scanned: Debian amavisd-new at valinux.co.jp Received: from mail.valinux.co.jp ([127.0.0.1]) by localhost (mail.valinux.co.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fMzRV-S21IYM; Wed, 22 Aug 2018 16:49:45 +0900 (JST) Received: from brer (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with ESMTP id A6DF1B39D3; Wed, 22 Aug 2018 16:49:45 +0900 (JST) From: =?iso-2022-jp?B?TUlOT1VSQSBNYWtvdG8gLyAbJEJMJzE6GyhCIBskQj8/GyhC?= To: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] x86/kvm/vmx: Fix GPF on reading vmentry_l1d_flush Date: Wed, 22 Aug 2018 16:49:45 +0900 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When EPT is not enabled, reading /sys/module/kvm_intel/parameters/vmentry_l1d_flush causes general protection fault in vmentry_l1d_flush_get() due to access beyond the end of the array vmentry_l1d_param[]. Signed-off-by: Minoura Makoto --- arch/x86/include/asm/vmx.h | 1 + arch/x86/kvm/vmx.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h index 95f9107449bf..c4b834b05178 100644 --- a/arch/x86/include/asm/vmx.h +++ b/arch/x86/include/asm/vmx.h @@ -581,6 +581,7 @@ enum vmx_l1d_flush_state { VMENTER_L1D_FLUSH_NEVER, VMENTER_L1D_FLUSH_COND, VMENTER_L1D_FLUSH_ALWAYS, + VMENTER_L1D_FLUSH_PARAM_MAX = VMENTER_L1D_FLUSH_ALWAYS, VMENTER_L1D_FLUSH_EPT_DISABLED, VMENTER_L1D_FLUSH_NOT_REQUIRED, }; diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 1519f030fd73..155ba2a9139f 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -204,6 +204,8 @@ static const struct { {"never", VMENTER_L1D_FLUSH_NEVER}, {"cond", VMENTER_L1D_FLUSH_COND}, {"always", VMENTER_L1D_FLUSH_ALWAYS}, + {"ept-disabled", VMENTER_L1D_FLUSH_EPT_DISABLED}, + {"not-required", VMENTER_L1D_FLUSH_NOT_REQUIRED}, }; #define L1D_CACHE_ORDER 4 @@ -286,7 +288,7 @@ static int vmentry_l1d_flush_parse(const char *s) unsigned int i; if (s) { - for (i = 0; i < ARRAY_SIZE(vmentry_l1d_param); i++) { + for (i = 0; i <= VMENTER_L1D_FLUSH_PARAM_MAX; i++) { if (sysfs_streq(s, vmentry_l1d_param[i].option)) return vmentry_l1d_param[i].cmd; }