From: Keir Fraser <keir@xensource.com>
To: Lukas Hejtmanek <xhejtman@ics.muni.cz>
Cc: Roland Dreier <rdreier@cisco.com>, xen-devel@lists.xensource.com
Subject: Re: Question regarding SLAB corruption
Date: Mon, 09 Jul 2007 20:22:05 +0100 [thread overview]
Message-ID: <C2B8496F.A8ED%keir@xensource.com> (raw)
In-Reply-To: <C2B8411E.A8E4%keir@xensource.com>
[-- Attachment #1: Type: text/plain, Size: 260 bytes --]
On 9/7/07 19:46, "Keir Fraser" <keir@xensource.com> wrote:
> Anyway, attahced is a patch I just applied to our unstable Linux tree. It
> should fix this issue.
And here's *another* patch. It applies on top of the previous one (ie. you
need both).
-- Keir
[-- Attachment #2: swiotlb2.patch --]
[-- Type: application/octet-stream, Size: 2171 bytes --]
# HG changeset patch
# User kfraser@localhost.localdomain
# Date 1184008553 -3600
# Node ID 5684370b1c4d9911fd4118fdc472c3c7a9adfca3
# Parent 5a4e93508aa03799989b63f8413aeae7df87c576
swiotlb: Allow sync on arbitrary offsets into dma-mapped region.
Signed-off-by: Keir Fraser <keir@xensource.com>
diff -r 5a4e93508aa0 -r 5684370b1c4d arch/i386/kernel/swiotlb.c
--- a/arch/i386/kernel/swiotlb.c Mon Jul 09 20:00:19 2007 +0100
+++ b/arch/i386/kernel/swiotlb.c Mon Jul 09 20:15:53 2007 +0100
@@ -378,17 +378,25 @@ map_single(struct device *hwdev, struct
*/
slot_buf = buffer;
for (i = 0; i < nslots; i++) {
+ slot_buf.page += slot_buf.offset >> PAGE_SHIFT;
+ slot_buf.offset &= PAGE_SIZE - 1;
io_tlb_orig_addr[index+i] = slot_buf;
slot_buf.offset += 1 << IO_TLB_SHIFT;
- if (slot_buf.offset > PAGE_SIZE) {
- slot_buf.page++;
- slot_buf.offset -= PAGE_SIZE;
- }
}
if ((dir == DMA_TO_DEVICE) || (dir == DMA_BIDIRECTIONAL))
__sync_single(buffer, dma_addr, size, DMA_TO_DEVICE);
return dma_addr;
+}
+
+struct phys_addr dma_addr_to_phys_addr(char *dma_addr)
+{
+ int index = (dma_addr - iotlb_virt_start) >> IO_TLB_SHIFT;
+ struct phys_addr buffer = io_tlb_orig_addr[index];
+ buffer.offset += (long)dma_addr & ((1 << IO_TLB_SHIFT) - 1);
+ buffer.page += buffer.offset >> PAGE_SHIFT;
+ buffer.offset &= PAGE_SIZE - 1;
+ return buffer;
}
/*
@@ -400,7 +408,7 @@ unmap_single(struct device *hwdev, char
unsigned long flags;
int i, count, nslots = ALIGN(size, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT;
int index = (dma_addr - iotlb_virt_start) >> IO_TLB_SHIFT;
- struct phys_addr buffer = io_tlb_orig_addr[index];
+ struct phys_addr buffer = dma_addr_to_phys_addr(dma_addr);
/*
* First, sync the memory before unmapping the entry
@@ -440,8 +448,7 @@ static void
static void
sync_single(struct device *hwdev, char *dma_addr, size_t size, int dir)
{
- int index = (dma_addr - iotlb_virt_start) >> IO_TLB_SHIFT;
- struct phys_addr buffer = io_tlb_orig_addr[index];
+ struct phys_addr buffer = dma_addr_to_phys_addr(dma_addr);
BUG_ON((dir != DMA_FROM_DEVICE) && (dir != DMA_TO_DEVICE));
__sync_single(buffer, dma_addr, size, dir);
}
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next prev parent reply other threads:[~2007-07-09 19:22 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-08 0:54 Question regarding SLAB corruption Lukas Hejtmanek
2007-07-08 9:59 ` Keir Fraser
2007-07-08 10:05 ` Lukas Hejtmanek
2007-07-08 10:11 ` Keir Fraser
2007-07-09 7:38 ` Lukas Hejtmanek
2007-07-09 8:02 ` Tian, Kevin
2007-07-09 8:31 ` Keir Fraser
2007-07-09 12:07 ` Lukas Hejtmanek
2007-07-09 12:47 ` Keir Fraser
2007-07-09 13:24 ` Lukas Hejtmanek
2007-07-09 13:42 ` Keir Fraser
2007-07-09 15:39 ` Lukas Hejtmanek
2007-07-09 16:13 ` Keir Fraser
2007-07-09 17:11 ` Lukas Hejtmanek
2007-07-09 17:21 ` Keir Fraser
2007-07-09 17:42 ` Lukas Hejtmanek
2007-07-09 18:29 ` Keir Fraser
2007-07-09 18:37 ` Lukas Hejtmanek
2007-07-09 18:46 ` Keir Fraser
2007-07-09 19:22 ` Keir Fraser [this message]
2007-07-09 19:43 ` Lukas Hejtmanek
2007-07-09 21:18 ` Keir Fraser
2007-07-09 21:26 ` Lukas Hejtmanek
2007-07-09 21:50 ` Lukas Hejtmanek
2007-07-09 19:25 ` Roland Dreier
2007-07-09 19:39 ` Keir Fraser
2007-07-09 20:56 ` Lukas Hejtmanek
2007-07-09 21:07 ` Roland Dreier
2007-07-09 21:14 ` Lukas Hejtmanek
2007-07-09 21:18 ` Roland Dreier
2007-07-09 21:42 ` Lukas Hejtmanek
2007-07-09 21:53 ` Roland Dreier
2007-07-09 22:13 ` Lukas Hejtmanek
2007-07-09 22:30 ` Keir Fraser
2007-07-09 22:30 ` Roland Dreier
2007-07-09 22:34 ` Keir Fraser
2007-07-10 18:47 ` Question: Dynamic code in x86_64 Xen Santos, Jose Renato G
2007-07-10 22:01 ` Keir Fraser
2007-07-10 22:06 ` Santos, Jose Renato G
2007-07-09 21:26 ` Question regarding SLAB corruption Roland Dreier
2007-07-09 21:33 ` Keir Fraser
2007-07-11 9:37 ` Question regarding vm creat&boot tgh
2007-07-09 19:21 ` Question regarding SLAB corruption Roland Dreier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=C2B8496F.A8ED%keir@xensource.com \
--to=keir@xensource.com \
--cc=rdreier@cisco.com \
--cc=xen-devel@lists.xensource.com \
--cc=xhejtman@ics.muni.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.