Received: by 10.192.165.156 with SMTP id m28csp3011391imm; Sun, 15 Apr 2018 14:58:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx49WPSi3un59EaDnr6O9T0+pzXGosPNOnY5SyEm35RFl3TFx47nP0ONx1OPKp8hZlx+ss3e3 X-Received: by 10.98.17.210 with SMTP id 79mr19376456pfr.65.1523829527052; Sun, 15 Apr 2018 14:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523829527; cv=none; d=google.com; s=arc-20160816; b=B6qpLWWAE7r1PE8MoYoXO9/R72D+qW1rPx/9HvomAe675y/FB0TD9RX6Pd/SYPPwhW +xDI/7IH1FjYlrCXVWSmMWWf22OepLdf2afhBiFncwrg3D2PSXACKukD9B5QbLo1JgLE KepjFXC5lCESID8cjMy5dU/h2vGUsFK5hwtVEXM9FXogXZVvRXGlxJ3JdcoBuNRTgsNa 8Ou8/g3zA4OdTNFmI8b0Z4EpxvpIlbKEYhIsvKvzOzfXG/iMEgYRlCDxzGU0HcxEGQJg HoZafOIbNdfcy1pUApKMAgybp4Ia4J9gq+NqC20s47G/jRPaano5S39gCyELXAK11MZ3 fw3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=7CBuK0xEvMCcWzUwU2a66kKmr8Fs+JzKZW3BqC74K9Q=; b=aDZGGge5Rso+FDu64hkx0pkhNNgQhgd8+0XqYwJUusr2ym2J0X7e4E1u2oU3nXbQz0 RRgwtbq3Tn3T9IW7cD28Z99zZF7IedMhFWdYA4uMWH+yxvajjMJEtuS2nlcTUVtQynQr TxbkWGsuPgHe3yxkw5cVTwl9PZn0jBdF535/dSuTLWOgBvfJZHuCCAUrDsanR9/dC2Nt nP5z762a+W7ZtAcUKvPQLwM+DtzjpzNXs/P2zxK7ndFCdsA+hEbtS5KVGp8fpbPIpUyy s6RG4lenYXA/ZsweRu+GYYTi5oJ9rtWZYrPg8PRomfM+E/KsiBXIEHHT6eK+EikplhiF vycg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=EDP29qGQ; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2-v6si10799067plk.51.2018.04.15.14.58.24; Sun, 15 Apr 2018 14:58:47 -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; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=EDP29qGQ; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753224AbeDOV4g (ORCPT + 99 others); Sun, 15 Apr 2018 17:56:36 -0400 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:7225 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752765AbeDOVzA (ORCPT ); Sun, 15 Apr 2018 17:55:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1523829300; x=1555365300; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=7CBuK0xEvMCcWzUwU2a66kKmr8Fs+JzKZW3BqC74K9Q=; b=EDP29qGQr2CMOnx3p5qEEaQcJfhnBzppUWMZnktd64QQeDyndNabFStn 8QgZzps5ApR+yFSoYwLB7FLr2Gnv0/P4t/tdP1fKVw1xWZPUgG9Qr2/sO UHNUmf/lMJRF6RAGCZKJpOlis5cmUVYtoodspqTWZTS/25KKkd7dNR6wU k=; X-IronPort-AV: E=Sophos;i="5.48,456,1517875200"; d="scan'208";a="726275416" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-2b-c7131dcf.us-west-2.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 15 Apr 2018 21:54:57 +0000 Received: from u54e1ad5160425a4b64ea.ant.amazon.com (pdx2-ws-svc-lb17-vlan3.amazon.com [10.247.140.70]) by email-inbound-relay-2b-c7131dcf.us-west-2.amazon.com (8.14.7/8.14.7) with ESMTP id w3FLssNe035413 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 15 Apr 2018 21:54:55 GMT Received: from u54e1ad5160425a4b64ea.ant.amazon.com (localhost [127.0.0.1]) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTP id w3FLsrNI013456; Sun, 15 Apr 2018 23:54:53 +0200 Received: (from karahmed@localhost) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Submit) id w3FLsrMi013455; Sun, 15 Apr 2018 23:54:53 +0200 From: KarimAllah Ahmed To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com Cc: KarimAllah Ahmed Subject: [PATCH v2 09/12] KVM/X86: Use kvm_vcpu_map in emulator_cmpxchg_emulated Date: Sun, 15 Apr 2018 23:53:15 +0200 Message-Id: <1523829198-13236-10-git-send-email-karahmed@amazon.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523829198-13236-1-git-send-email-karahmed@amazon.de> References: <1523829198-13236-1-git-send-email-karahmed@amazon.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use kvm_vcpu_map in emulator_cmpxchg_emulated since using kvm_vcpu_gpa_to_page() and kmap() will only work for guest memory that has a "struct page". Signed-off-by: KarimAllah Ahmed --- v1 -> v2: - Update to match the new API return codes --- arch/x86/kvm/x86.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 4633674..8d08c11 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5162,9 +5162,9 @@ static int emulator_cmpxchg_emulated(struct x86_emulate_ctxt *ctxt, unsigned int bytes, struct x86_exception *exception) { + struct kvm_host_map map; struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt); gpa_t gpa; - struct page *page; char *kaddr; bool exchanged; @@ -5181,12 +5181,11 @@ static int emulator_cmpxchg_emulated(struct x86_emulate_ctxt *ctxt, if (((gpa + bytes - 1) & PAGE_MASK) != (gpa & PAGE_MASK)) goto emul_write; - page = kvm_vcpu_gfn_to_page(vcpu, gpa >> PAGE_SHIFT); - if (is_error_page(page)) + if (kvm_vcpu_map(vcpu, gpa_to_gfn(gpa), &map)) goto emul_write; - kaddr = kmap_atomic(page); - kaddr += offset_in_page(gpa); + kaddr = map.hva + offset_in_page(gpa); + switch (bytes) { case 1: exchanged = CMPXCHG_TYPE(u8, kaddr, old, new); @@ -5203,8 +5202,8 @@ static int emulator_cmpxchg_emulated(struct x86_emulate_ctxt *ctxt, default: BUG(); } - kunmap_atomic(kaddr); - kvm_release_page_dirty(page); + + kvm_vcpu_unmap(&map); if (!exchanged) return X86EMUL_CMPXCHG_FAILED; -- 2.7.4