From patchwork Fri Jan 29 09:32:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alvise Rigo X-Patchwork-Id: 575549 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2D1A614056B for ; Fri, 29 Jan 2016 20:35:41 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=virtualopensystems-com.20150623.gappssmtp.com header.i=@virtualopensystems-com.20150623.gappssmtp.com header.b=v/alDrK/; dkim-atps=neutral Received: from localhost ([::1]:60725 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aP5St-0004jD-1g for incoming@patchwork.ozlabs.org; Fri, 29 Jan 2016 04:35:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aP5QW-0007Y3-B9 for qemu-devel@nongnu.org; Fri, 29 Jan 2016 04:33:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aP5QV-0000VU-AQ for qemu-devel@nongnu.org; Fri, 29 Jan 2016 04:33:12 -0500 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:35116) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aP5QV-0000UY-08 for qemu-devel@nongnu.org; Fri, 29 Jan 2016 04:33:11 -0500 Received: by mail-wm0-x232.google.com with SMTP id r129so60077738wmr.0 for ; Fri, 29 Jan 2016 01:33:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtualopensystems-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lI81UgIg0zRZgYN0ovhRH8B18OFtIyOFTvvaAbWT7uA=; b=v/alDrK/TO5Sjf+fuXyXyvyMkOvqgrDLZRNTGo7L853Hb39FRac/iDtYubTiebzfp0 rnQswFriJNcqhQeqEn9qiy9eM4x5vRgxM/G6z6ys3KJy26Rl+/WG4PARcEoAtaObhVeD oZHjgs+3WJYnJP+Wo0orVPbJzCwwThRzagNVkJsLAqVn/I5I9yWIM01uyr+Pol4owmPH efDAn9XbSNWT8EjzSSjVobM5UfIAJmfJfkR+LwMqmWkwJHmSspO98+kEld1n2NNc7txM Q5i89zXvSKPB78BDLuUuISiOW3zGtv5vxcRCy9Wgi65+5cDcldvW1k1JoqrxGGHFeGz5 uZRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lI81UgIg0zRZgYN0ovhRH8B18OFtIyOFTvvaAbWT7uA=; b=Q8US62INcVooRUvV0cpZvjf2f9Me4CAV3wuvWP4nQQEFlxdMtfjQCtj2t0hoVmLEtL KCR1GOLk1ziyz6lTFRTUb5gEppSPgKrYCG93sRiICX3R66qO9ARXZQKAXdGGsfX4Yjzs 0/6AS1geEQPR/5n/Mq8hGt1LrzI1QqtK5wEOkOf6uF8PN72jbtLzxXNnupXQeo2Jb6px FU1CB4cKGygDLzTc4RYObVSi12QyG9VSA9UgQ+fQI06ZHaOl1Va+m2PUykA8ojedDrrg oxny+OQtF179VRX0sW1B+fYJjZE3F2WnYPs3wQx6O9d8mqx3LfwZkagJGGhDVp8KORnj eVFw== X-Gm-Message-State: AG10YOThz9Bq7GA2OI66O6iv29DZZ+PFdi7iKavYEX0JFCIiM/ELqkP8VLHkvJggR4UxDQ== X-Received: by 10.194.93.102 with SMTP id ct6mr9025212wjb.157.1454059990381; Fri, 29 Jan 2016 01:33:10 -0800 (PST) Received: from localhost.localdomain (LPuteaux-656-1-278-113.w80-15.abo.wanadoo.fr. [80.15.154.113]) by smtp.googlemail.com with ESMTPSA id o7sm14765451wjf.45.2016.01.29.01.33.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jan 2016 01:33:09 -0800 (PST) From: Alvise Rigo To: qemu-devel@nongnu.org, mttcg@listserver.greensocs.com Date: Fri, 29 Jan 2016 10:32:38 +0100 Message-Id: <1454059965-23402-10-git-send-email-a.rigo@virtualopensystems.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1454059965-23402-1-git-send-email-a.rigo@virtualopensystems.com> References: <1454059965-23402-1-git-send-email-a.rigo@virtualopensystems.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::232 Cc: claudio.fontana@huawei.com, pbonzini@redhat.com, jani.kokkonen@huawei.com, tech@virtualopensystems.com, alex.bennee@linaro.org, rth@twiddle.net Subject: [Qemu-devel] [RFC v7 09/16] softmmu: Include MMIO/invalid exclusive accesses X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Enable exclusive accesses when the MMIO/invalid flag is set in the TLB entry. In case a LL access is done to MMIO memory, we treat it differently from a RAM access in that we do not rely on the EXCL bitmap to flag the page as exclusive. In fact, we don't even need the TLB_EXCL flag to force the slow path, since it is always forced anyway. This commit does not take care of invalidating an MMIO exclusive range from other non-exclusive accesses i.e. CPU1 LoadLink to MMIO address X and CPU2 writes to X. This will be addressed in the following commit. Suggested-by: Jani Kokkonen Suggested-by: Claudio Fontana Signed-off-by: Alvise Rigo --- cputlb.c | 7 +++---- softmmu_template.h | 26 ++++++++++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/cputlb.c b/cputlb.c index aa9cc17..87d09c8 100644 --- a/cputlb.c +++ b/cputlb.c @@ -424,7 +424,7 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, if ((memory_region_is_ram(section->mr) && section->readonly) || memory_region_is_romd(section->mr)) { /* Write access calls the I/O callback. */ - te->addr_write = address | TLB_MMIO; + address |= TLB_MMIO; } else if (memory_region_is_ram(section->mr) && cpu_physical_memory_is_clean(section->mr->ram_addr + xlat)) { @@ -437,11 +437,10 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, if (cpu_physical_memory_is_excl(section->mr->ram_addr + xlat)) { /* There is at least one vCPU that has flagged the address as * exclusive. */ - te->addr_write = address | TLB_EXCL; - } else { - te->addr_write = address; + address |= TLB_EXCL; } } + te->addr_write = address; } else { te->addr_write = -1; } diff --git a/softmmu_template.h b/softmmu_template.h index 267c52a..c54bdc9 100644 --- a/softmmu_template.h +++ b/softmmu_template.h @@ -476,7 +476,7 @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, /* Handle an IO access or exclusive access. */ if (unlikely(tlb_addr & ~TARGET_PAGE_MASK)) { - if ((tlb_addr & ~TARGET_PAGE_MASK) == TLB_EXCL) { + if (tlb_addr & TLB_EXCL) { CPUIOTLBEntry *iotlbentry = &env->iotlb[mmu_idx][index]; CPUState *cpu = ENV_GET_CPU(env); CPUClass *cc = CPU_GET_CLASS(cpu); @@ -500,8 +500,15 @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, } } - glue(helper_le_st_name, _do_ram_access)(env, val, addr, oi, - mmu_idx, index, retaddr); + if (tlb_addr & ~(TARGET_PAGE_MASK | TLB_EXCL)) { /* MMIO access */ + glue(helper_le_st_name, _do_mmio_access)(env, val, addr, oi, + mmu_idx, index, + retaddr); + } else { + glue(helper_le_st_name, _do_ram_access)(env, val, addr, oi, + mmu_idx, index, + retaddr); + } lookup_and_reset_cpus_ll_addr(hw_addr, DATA_SIZE); @@ -620,7 +627,7 @@ void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, /* Handle an IO access or exclusive access. */ if (unlikely(tlb_addr & ~TARGET_PAGE_MASK)) { - if ((tlb_addr & ~TARGET_PAGE_MASK) == TLB_EXCL) { + if (tlb_addr & TLB_EXCL) { CPUIOTLBEntry *iotlbentry = &env->iotlb[mmu_idx][index]; CPUState *cpu = ENV_GET_CPU(env); CPUClass *cc = CPU_GET_CLASS(cpu); @@ -644,8 +651,15 @@ void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, } } - glue(helper_be_st_name, _do_ram_access)(env, val, addr, oi, - mmu_idx, index, retaddr); + if (tlb_addr & ~(TARGET_PAGE_MASK | TLB_EXCL)) { /* MMIO access */ + glue(helper_be_st_name, _do_mmio_access)(env, val, addr, oi, + mmu_idx, index, + retaddr); + } else { + glue(helper_be_st_name, _do_ram_access)(env, val, addr, oi, + mmu_idx, index, + retaddr); + } lookup_and_reset_cpus_ll_addr(hw_addr, DATA_SIZE);