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 X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FF7EC4338F for ; Thu, 5 Aug 2021 11:23:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A4AB60EE5 for ; Thu, 5 Aug 2021 11:23:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240791AbhHELXw (ORCPT ); Thu, 5 Aug 2021 07:23:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30240 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240731AbhHELXu (ORCPT ); Thu, 5 Aug 2021 07:23:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628162615; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5Fd84Q4wmp1HHp9/8faQUi9ZHuuSm34D/5/TWDWrlNs=; b=F6y71Mx4YfDQZSDQj0ui1O4xqnOiIlc9VwJ0vvdxs3OTqP2U9gEL/Iu/PlztIRRk7ZlOO3 tDuyoiOsLqdAoYfMgp2jc+VbgqSb+VRCi8dCP9taw9hknZ79s0FKPbUYvziayzy2/3jgIv Wz6gtmdyEzt2VCNm0nWpvHbZKO2TcTg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-231-wixwhbkRN3qmj4jFdc4rcQ-1; Thu, 05 Aug 2021 07:23:32 -0400 X-MC-Unique: wixwhbkRN3qmj4jFdc4rcQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EC9E291199; Thu, 5 Aug 2021 11:23:28 +0000 (UTC) Received: from starship (unknown [10.35.206.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id F120D60E1C; Thu, 5 Aug 2021 11:23:20 +0000 (UTC) Message-ID: Subject: Re: [PATCH] selftests: KVM: avoid failures due to reserved HyperTransport region From: Maxim Levitsky To: Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: stable@vger.kernel.org, David Matlack Date: Thu, 05 Aug 2021 14:23:19 +0300 In-Reply-To: <20210805105423.412878-1-pbonzini@redhat.com> References: <20210805105423.412878-1-pbonzini@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2021-08-05 at 06:54 -0400, Paolo Bonzini wrote: > Accessing guest physical addresses at 0xFFFD_0000_0000 and above causes > a failure on AMD processors because those addresses are reserved by > HyperTransport (this is not documented). Avoid selftests failures > by reserving those guest physical addresses. > > Fixes: ef4c9f4f6546 ("KVM: selftests: Fix 32-bit truncation of vm_get_max_gfn()") > Cc: stable@vger.kernel.org > Cc: David Matlack > Reported-by: Maxim Levitsky > Signed-off-by: Paolo Bonzini > --- > tools/testing/selftests/kvm/lib/kvm_util.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c > index 10a8ed691c66..d995cc9836ee 100644 > --- a/tools/testing/selftests/kvm/lib/kvm_util.c > +++ b/tools/testing/selftests/kvm/lib/kvm_util.c > @@ -309,6 +309,12 @@ struct kvm_vm *vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm) > /* Limit physical addresses to PA-bits. */ > vm->max_gfn = ((1ULL << vm->pa_bits) >> vm->page_shift) - 1; > > +#ifdef __x86_64__ > + /* Avoid reserved HyperTransport region on AMD processors. */ > + if (vm->pa_bits == 48) > + vm->max_gfn = 0xfffcfffff; > +#endif > + > /* Allocate and setup memory for guest. */ > vm->vpages_mapped = sparsebit_alloc(); > if (phy_pages != 0) I probably would have restricted this workaround to AMD vendor string, but I don't mind this to be like that as well at least for now. Reviewed-by: Maxim Levitsky Best regards, Maxim Levitsky