Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp38399imu; Tue, 22 Jan 2019 13:21:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN5XzhGhQjyZS1T/ZJvME57mXEfsX3XBEM64/9fR/65WFjx3y+MJKFKx+3RTKh5CA3CShk7Y X-Received: by 2002:a63:a553:: with SMTP id r19mr33278864pgu.53.1548192115228; Tue, 22 Jan 2019 13:21:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548192115; cv=none; d=google.com; s=arc-20160816; b=rGxv6HNYBa+g/jePb4seQ0KQ3XFuvMvqXvNi2UNibnEmeniIpKTP7r63Nuhz3+Pbj0 Y2s5qD0Dxs1dQN37sMhgPzHWKvMsEs/+GsAe1P6zEIBj4FZgKttByyCB1eZwQ1NmKYJC C+YFK5ilr0VX2RdxXQh5Z+z05+0nNMdqRwLvLztox2vQnJePjM4kgMfnt26qKrwH3JxF nqrFeJjra3MwATLEdFbfn87OVyqVgHZtbkbUDnCCSCifxG7oA1Ok+iV2JCpi0wcT8sKV wDL7DsYocwpX2kx80WynxB8yCHyPSkqATyW9wU39H87wLAS67GwZdCd286CW7E3DyS/Y ZhWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from; bh=zgORWJQyoJby9R9CX4g4ZWDCKqwAx53jtsrlBrgJ3Gs=; b=AlOZCO9LmmDBFkjVRNw4cdYh+W8QQlZRkkeF3+sv6zw3UAGarJB8kL6RfgaXCr4SaL X5eE6eCr7y1qTIkftmhRU4lajv5fK4PVbdJx/LLk2IeUAlSnXf5yc8clpw8fjGLM5K9n iOBgrsKJi6DSVkpSVo7tPa/nvYTv4gDlO9WR42gDynp7SmHhgPPzjWtyLvQv/sgxplWK J2mUS0Rh/ogizh0/ymlvDFZ+nCW1XFeRwWHq4AMkLozpE0fygkz8yjOMRx+elKNPsQcy 7zjH773FfhBrImrbaZSR47kYyJkD10G5q2L4Z9w726bOqOc0LCzFC3HIXWAyRcx0pQY3 1+/g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1si17190435pld.353.2019.01.22.13.21.34; Tue, 22 Jan 2019 13:21:55 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726958AbfAVVSy (ORCPT + 99 others); Tue, 22 Jan 2019 16:18:54 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:49522 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726948AbfAVVSy (ORCPT ); Tue, 22 Jan 2019 16:18:54 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0MLIrxU042111 for ; Tue, 22 Jan 2019 16:18:53 -0500 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 2q682cexke-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 22 Jan 2019 16:18:52 -0500 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 22 Jan 2019 21:18:44 -0000 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 22 Jan 2019 21:18:38 -0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0MLIbFY18940068 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 22 Jan 2019 21:18:37 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 87D1CBE058; Tue, 22 Jan 2019 21:18:37 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49DC5BE053; Tue, 22 Jan 2019 21:18:33 +0000 (GMT) Received: from morokweng.localdomain.com (unknown [9.85.185.73]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 22 Jan 2019 21:18:32 +0000 (GMT) From: Thiago Jung Bauermann To: x86@kernel.org Cc: kvm@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Marek Szyprowski , Robin Murphy , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Tom Lendacky , Ram Pai , Thiago Jung Bauermann Subject: [PATCH 2/2] x86/kvmclock: set_memory_decrypted() takes number of pages Date: Tue, 22 Jan 2019 19:17:58 -0200 X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190122211758.8317-1-bauerman@linux.ibm.com> References: <20190122211758.8317-1-bauerman@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19012221-0020-0000-0000-00000EAFA7B1 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010457; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000275; SDB=6.01150302; UDB=6.00599446; IPR=6.00930634; MB=3.00025244; MTD=3.00000008; XFM=3.00000015; UTC=2019-01-22 21:18:42 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19012221-0021-0000-0000-00006484B392 Message-Id: <20190122211758.8317-2-bauerman@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-22_11:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=38 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=917 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901220160 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ram Pai set_memory_decrypted() expects the number of PAGE_SIZE pages to decrypt. kvmclock_init_mem() instead passes number of bytes. This decrypts a huge number of pages resulting in data corruption. Fixed it. [ bauermann: Slightly reworded commit message and added Fixes: tag. ] Fixes: 6a1cac56f41f ("x86/kvm: Use __bss_decrypted attribute in shared variables") Signed-off-by: Ram Pai Signed-off-by: Thiago Jung Bauermann --- arch/x86/kernel/kvmclock.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) Note: Found by code inspection. I don't have a way to test. diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c index e811d4d1c824..b5c867dd2c8d 100644 --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c @@ -251,8 +251,7 @@ static void __init kvmclock_init_mem(void) * be mapped decrypted. */ if (sev_active()) { - r = set_memory_decrypted((unsigned long) hvclock_mem, - 1UL << order); + r = set_memory_decrypted((unsigned long) hvclock_mem, 1); if (r) { __free_pages(p, order); hvclock_mem = NULL;