Commit Graph

334 Commits

Author SHA1 Message Date
jld
12c1c974f7 Use 64-bit intermediate in get_tsc_offset_ns to avoid overflow.
Discussed (3 weeks ago) on port-xen; okayed by yamt@, bouyer@.
2006-02-03 04:59:03 +00:00
bouyer
86110231a4 Check the destination ethernet address when not in promiscous mode.
Fix problem where packets would be duplicated, possibly looping, when
a domU is doing IP routing.
Problem reported and fix tested by Mike M. Volokhov on port-xen

While there, add some __predict_false/true in conditionnals where
appropriate, remove a always-true test, and fix handling of
mbuf shortage.
2006-02-01 19:12:02 +00:00
bouyer
ea223f367a Fif off-by-one error: the last byte of a packet is at offset len - 1,
not len.
Should fix KASSERT panic reported by Mike M. Volokhov on port-xen.
2006-01-26 19:17:25 +00:00
yamt
3bf197127a merge xen pmap_enter, pmap_enter_ma, pmap_remap_pages.
ok'ed by Manuel Bouyer.
2006-01-23 20:19:08 +00:00
bouyer
4021f3f608 Fix bad cut'n'paste: use the target of strncpy() in sizeof(). 2006-01-22 20:15:51 +00:00
bouyer
87d63b6c1c Remove files not needed in the kernel. 2006-01-20 18:17:59 +00:00
bouyer
8f162b7ed8 Snapshot of work in progress on NetBSD port to Xen3:
- kernel (both dom0 and domU) boot, console is functionnal and it can starts
  software from a ramdisk
- there is no driver front-end expect console for domU yet.
- dom0 can probe devices and ex(4) work when Xen3 is booted without acpi
  and apic support. But the on-board IDE doens't get interrupts.
  The PCI code still needs work (it's hardcoded to mode 1). Some of this
  code should be shared with ../x86
  The physical insterrupt code needs to get MPBIOS and ACPI support, and
  do interrupt routing to properly interract with Xen.
To enable Xen-3.0 support, add
options XEN3
to your kernel config file (this will disable Xen2 support)
Changes affecting Xen-2.0 support (no functionnal changes intended):
- get more constants from genassym for assembly code
- remove some unneeded registers move from start()
- map the shared info page from start(), and remove the pte = 0xffffffff hack
- vector.S: in hypervisor_callback() make sure %esi points to
  HYPERVISOR_shared_info before accessing the info page. Remplace some
  hand-written assembly with the equivalent macro defined in frameasm.h
- more debug code, dissabled by default.

while here added my copyright on some files I worked on in 2005.
2006-01-15 22:09:51 +00:00
bouyer
5e035a6853 Import Xen3 public headers from xen-3.0-testing as of 7 Jan 2006. 2006-01-15 21:42:21 +00:00
yamt
468012e183 privcmd_ioctl: wrap IOCTL_PRIVCMD_INITDOMAIN_EVTCHN_OLD in #ifdef COMPAT_30. 2006-01-14 11:03:35 +00:00
bouyer
3c69e23dad ctrl_if.h isn't needed here. 2006-01-08 19:00:59 +00:00
bouyer
56b1a39e10 Move if_xennet private functions and structures from if_xennetvar.h
to if_xennet.c
2006-01-08 14:45:41 +00:00
bouyer
4f02289d67 Make stts a no-op as clts already is
Always call HYPERVISOR_fpu_taskswitch() at the end of npxsave_lwp().

This fixes the FPU problems detected by paranoia on a NetBSD/Xen guest.
Based on patch sent by Paul Ripke on port-xen, but reworked by me.
Should fix port-xen/30977.
2006-01-03 20:18:51 +00:00
jmmv
eb23406894 Add a 'struct bootinfo' to represent the bootinfo structure used in the
kernel by x86 platforms (instead of a simple char *).  This way, the code
in, e.g., lookup_bootinfo, is a bit easier to understand.

While here, move the lookup_bootinfo function used in x86 platforms (amd64,
i386 and xen) to a common file (x86/x86_machdep.c), as it was exactly the
same in all of them.
2005-12-30 13:37:57 +00:00
perry
2d542ba1f8 inline -> __inline 2005-12-28 19:09:29 +00:00
yamt
9297401d54 - add ioctls to set/get disk bufq strategy.
- implement them for some drivers.
2005-12-26 10:36:47 +00:00
perry
50a256a3a0 __asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
2005-12-24 23:23:59 +00:00
perry
5f1c88d70d Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete. 2005-12-24 20:06:46 +00:00
yamt
50c06dae27 xennet_softstart: turn "xennet: no mbuf cluster" printf to DPRINTF. 2005-12-15 13:45:32 +00:00
yamt
6b6b3253b2 fix a compilation problem after ktrace-lwp merge. 2005-12-13 08:24:30 +00:00
jld
341dd78856 Make xenevt.c compile after lwp changes; not tested yet. 2005-12-12 22:56:50 +00:00
christos
24ecd917a6 change a_p -> a_l->l_proc [untested] 2005-12-12 20:06:22 +00:00
christos
95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
yamt
30e4cf555e remove xen-specific ddb_trap_hook.
you can use DDB_COMMANDONENTER="tr;sh re" to achive the similar behaviour.
2005-11-26 12:19:53 +00:00
yamt
bc21da4cfb bus_dmamem_map: honour BUS_DMA_NOWAIT. noted by Manuel Bouyer.
bus_space_map: always do NOWAIT allocation as it used to be before yamt-km.

we have too many copies!
2005-11-24 13:08:32 +00:00
yamt
73ad976942 simplify memory layout. 2005-11-22 06:18:01 +00:00
bouyer
c59d1285cc Sync with i386/conf/GENERIC:
- add a buch of PCI storage devices
- add firewire devices
- add some missing PCI network devices
- add serial and parallel PCI adapters
- add lpt0 at isa
- add com1 at isa
  com0 not added for the benefit of serial console users (it will conflicts
  with the Xen kernel).
XXX this means that setups with serial console on com1 will now break with the
default kernel.
Use userconf(4) (add -c to kernel command line) or change your setup to
com0 instead (most bios allows arbitrary mappings of com ports)
2005-11-21 22:15:13 +00:00
jld
55b8d39e63 Correct minor precedence mistakes in updates to pm_stats.wired_count 2005-11-16 22:41:20 +00:00
yamt
4868e1f967 add missing IPL_SOFTXENEVT.
pointed by Hisashi T Fujinaka on current-users@.
2005-11-08 22:57:30 +00:00
yamt
06cf1c7649 copy.S should belong to MD_SFILES, not MD_CFILES. 2005-11-08 01:02:39 +00:00
yamt
443e88c5cf some assym cleanup.
- move copyin and friends from locore.S to their own file, copy.S.
  share it between i386 and xen.
- defparam KERNBASE and kill KERNBASE_LOCORE hack.
- add more symbols to assym.h and use it where appropriate.
2005-11-07 11:42:34 +00:00
yamt
83c44381ee Xsoftnet: remove an unnecessary assignment. 2005-11-07 08:52:07 +00:00
yamt
06085e8f52 - use sys/spl.h.
- add some IPL_ definitions.
2005-11-03 13:06:06 +00:00
yamt
0416d5be24 add splraiseipl(). 2005-10-29 11:07:45 +00:00
yamt
54007a40c0 remove duplicated spllpt(). 2005-10-28 10:34:18 +00:00
yamt
464cf44f6c dksubr: do b_blkno -> b_rawblkno translation earlier so that bufq can uses it. 2005-10-18 00:14:43 +00:00
yamt
aec75b1cc6 - change the way to specify a bufq strategy. (by string rather than by number)
- rather than embedding bufq_state in driver softc,
  have a pointer to the former.
- move bufq related functions from kern/subr_disk.c to kern/subr_bufq.c.
- rename method to strategy for consistency.
- move some definitions which don't need to be exposed to the rest of kernel
  from sys/bufq.h to sys/bufq_impl.h.
  (is it better to move it to kern/ or somewhere?)
- fix some obvious breakage in dev/qbus/ts.c.  (not tested)
2005-10-15 17:29:10 +00:00
bouyer
65679198a8 Also remove pkt_next now that packets are not recorded in a per-page list. 2005-10-08 20:23:59 +00:00
bouyer
0e12d49f1c If a domain has more than one interface, a page can hold packets for different
xennetback instances. To support this, more fields from xni_page to xni_pkt.
This would also have the effect to move more code into the
while (!SLIST_EMPTY(&pkt_page->xni_pkt_head)) loop in xennetback_tx_free().
By passing xni_pkt instead of xni_page to xennetback_tx_free we can
avoid the loop, and the xni_pkt_head list completely. There is even a sligh
performance increase if the domU deals with xni_txring->event properly.

Based on comments from YAMAMOTO Takashi.
2005-10-08 20:22:05 +00:00
bouyer
181bca1deb Fix problem pointed out by YAMAMOTO Takashi:
In theory mbufs can have an infinite life time and could block the transmit
ring (as slots are released when the mbuf external storage is freed). To
avoid this, when we're processing the last slot of the ring copy the buffer
and release the slot immediatly.
2005-10-03 22:15:44 +00:00
bouyer
213d74cfef Major improvements to the network backend, leading to a 0-copy transmit and
receive system:
- on the receive side, attach the mapped buffer as external storage
  instead of copying it. As a mapped buffer may not live much longer, we
  have to deal with the fact that one page of buffer may containt several
  packets, and it's not possible to map them several times. Use a hashed list
  to keep track of mapped pages, and use reference counters.
- on the transmit side, when MCLBYTES == PAGE_SIZE, give away the mbuf
  cluster page when possible instead of copying it. Keep a pool of physical
  pages to map in place of the page we give away. When copying, use a
  pool_cache(9) to manage copy buffers (use mclpool_cache when
  MCLBYTES == PAGE_SIZE, otherwise use a private pool/pool_cache) instead
  of a local list. This should reduce the number of hypercalls and MMU
  operations in the copy case as well.
2005-10-02 21:49:23 +00:00
bouyer
8b47a87eb6 Have xennet_start() schedule a software interrupt to defer processing of the
send queue. This give upper layer an opportunity to queue up all available
packets before starting to process them. This reduce the number of interrupt
generated on the backend, and the time spent doing hypercalls in a significant
way.
2005-10-02 21:39:41 +00:00
bouyer
8519a64973 inline 2 trivial functions that are called often (according to profiling
data).
2005-09-20 20:33:53 +00:00
bouyer
0b1f7e4a8c When disconnecting a device, we have to wait for pending I/O before releasing
the ressources (this can lead to a dom0 kernel crash when destroying a domain
with active I/O going). For this, add a refcount to struct xbdback_instance,
and defer CMSG_BLKIF_BE_DISCONNECT reply until refcount is back to 0 (which
means all queued buffers have completed).
Based on patch sent by Jed Davis on port-xen.
2005-09-20 20:29:18 +00:00
yamt
7e71f567e4 include "conf/std". 2005-09-17 09:44:05 +00:00
bouyer
241368ab96 Check that m_copyback() didn't fail. Pointed out by YAMAMOTO Takashi. 2005-09-12 16:30:46 +00:00
yamt
55dd3a28d4 remove no longer used macros. 2005-09-12 12:41:06 +00:00
yamt
8dcf8ba6e2 xennet_start: don't allocate cluster mbufs unless needed. 2005-09-12 12:40:43 +00:00
chs
c36910e9cd remove the part of rev. 1.168 that skips TLB invalidations in pmap_enter().
it's wrong for wired mappings.  fixes PR 29804.
2005-09-11 14:30:31 +00:00
bouyer
4f6680c241 Use MCLGET() instead of local list of buffers. Garbage-collect
struct xennet_txbuf usage.
2005-09-11 13:20:00 +00:00
bouyer
acad751169 Remplace MEXTMALLOC/memcpy with m_copyback. 2005-09-11 11:44:52 +00:00
bouyer
b069bb656c The line number in the PCI interrupt register can be larger than 31 on
some hardware, depending on how Xen set things up. So bump NR_PIRQ from 32
to 256.
2005-09-10 18:24:35 +00:00
bouyer
b75ba03dd4 Add a vm_prot_t parameter to pmap_remap_pages(), and use it for the new PTE
instead to always trying PG_RW and falling back to PG_RO if this fails.
Use uvm_map_checkprot() in IOCTL_PRIVCMD_MMAP and IOCTL_PRIVCMD_MMAP_BATCH
to compute the appropriate vm_prot_t for pmap_remap_pages().
Thanks to Jed Davis for pointing out uvm_map_checkprot().
2005-09-10 18:00:49 +00:00
bouyer
ba9c8cd0c3 Apply patch from Jed Davis, posted to port-xen:
Implement IOCTL_PRIVCMD_MMAPBATCH, as a loop calling pmap_remap_pages().
XXX this should do the MMU operations in batch.
2005-09-10 15:48:10 +00:00
bouyer
8dfe5bc813 Apply patch from Jed Davis, posted to port-xen:
In pmap_remap_pages() new mappings are created (PG_RW|PG_M). When saving
a domain, the hypervisor will refuse to map the foreing pages RW.
As a temporary measure, retry the mapping read-only if PG_RW fails, so that
domain save will work. Also fix the PTP's wire_count if the MMU update
fails (prevent a kernel panic).
2005-09-10 15:46:04 +00:00
bouyer
7558bd0a7c Fix typo reported by Jed Davis on port-xen:
IOCTL_PRIVCMD_GET_MACH2PHYS_START_MFN is a read, not a write.
2005-09-10 15:41:54 +00:00
kleink
aece7a90fd Change the driver open function's conditional for overriding exclusive tty
use from checking the proc's uid to suser(9), and account for the use of
privileges.  Noted by David Holland in PR kern/31126.
2005-09-06 21:40:37 +00:00
bouyer
f60ca60293 Rename _PRIVATE_BUS_DMAMEM_ALLOC_RANGE to _BUS_DMAMEM_ALLOC_RANGE for
consistency with other macros defined in bus_private.h. Pointed out by
YAMAMOTO Takashi.
2005-08-22 11:09:39 +00:00
bouyer
e6a6daf84f Fix a memory leak. Thanks to YAMAMOTO Takashi for the notice. 2005-08-22 11:04:10 +00:00
bouyer
d342a7617e Define a xendevbus atttibute and add it to hypervisor. Use it for xen devices
which attach to hypervisor. This allows to use config_found_ia() instead of
config_found(), instead of relying on the order of which device are
written in ioconf.c.
From Quentin Garnier.
2005-08-21 22:20:28 +00:00
yamt
6788570f66 xen_parse_cmdline:
- use BOOT_FLAG macro.
- allow RB_KDB because it works fine, depending on type of console.
2005-08-21 13:15:43 +00:00
yamt
1a3bee2634 - count if_opackets correctly.
- reflect tx errors to if_oerrors.
2005-08-21 13:12:59 +00:00
bouyer
cd1cc7810a Also properly check the alignement and boundary constraints. 2005-08-20 20:06:24 +00:00
bouyer
0944c0fa9d Deal with the machine address space being non-contigous in bus_dmamem_alloc():
- Define _BUS_AVAIL_END to 0xffffffff, as we don't have an easy way to
  find the upper bound for our machine address space (and this can change
  when we swap pages with the hypervisor).
- implement _xen_bus_dmamem_alloc_range(), which will request a contigous
  set of pages to the hypervisor if the pages returned by uvm_pglistalloc()
  don't fit the constraints.
We can't deal with the low/high constraints yet, because Xen doesn't offer a
way to get pages in a specific ranges of addresses.

Based on patches from Dave Thompson (in private mail), with heavy hacking
by me.
2005-08-20 19:30:37 +00:00
bouyer
54ecd3d8a1 Implement xpq_queue_machphys_update(), which queues a request to
update the machine to physical table (to be used after a
MEMOP_increase_reservation).
2005-08-20 19:20:54 +00:00
yamt
5cb036f6e3 add wedge support to xbd and cgd. 2005-08-20 12:03:52 +00:00
bouyer
41b1abf49b Provide a PCI_MACHDEP_ENUMERATE_BUS to the MI pci system. We can't use
the generic pci_enumerate_bus() in Xen because the hypervisor may
hide the function 0, but give access to other functions of the same device
and pci_enumerate_bus() will stop if function 0 isn't available.
2005-08-19 17:17:53 +00:00
bouyer
fa7d49200e Make PCI devices usable for non-domain0 kernels. Based on patches sent by
Ceri Storey to port-xen, with some additionnal changes by me:
- include bus_dma.c, bus_space.c and pci_machdep.c if pci is defined
  instead of dom0ops
- Make various initialisations, and probe/attach pci busses based on NPCI
  instead of DOM0OPS
- in conf/files.xen, move xen-specific devices before non-xen specific devices
  so that the xen-specific match function is called first, to avoid false
  attachement from too liberal match function in non-xen code.
2005-08-19 16:06:12 +00:00
cube
9f1eb3e30f Change all archs that did:
#define clockframe somethingelse

to:

struct clockframe {
	struct somethingelse cf_se;
};

and change access macros accordingly.

That means that, at least for that very issue, things will not go
ka-boomy if you don't have the actual definition of struct clockframe
before including systm.h.
2005-08-11 20:32:55 +00:00
yamt
afdf806bac wrap some code with #if defined(NFS_BOOT_BOOTSTATIC). 2005-08-07 04:54:58 +00:00
yamt
5923204be0 fix a race by re-checking req_prod when exiting main loop. 2005-07-19 12:20:29 +00:00
yamt
01fa457bff xen_shm_unmap:
- don't try to remove a request twice.
- fix spl/splx mismatch.
2005-07-19 11:09:52 +00:00
yamt
4ff72cab3e xbdback_co_main_loop: don't forget to set xbdi->cont in the case of error. 2005-07-19 09:45:12 +00:00
tls
0ac3367f2a Improvements to xbdback (the domain 0 driver that provides "xbd" virtual
disks to other domains) from Jed Davis, <jld@panix.com>:

	* Issue multiple requests when necessary rather than
	  assuming that arbitrary requests can be mapped into single
	  contiguous virtual address ranges.

	* Don't assume that all data for a request is consecutive
	  in memory.  With some client OSes, it's not.

	The above two changes fix data corruption issues with Linux
	clients with certain filesystem block sizes.

	* Gracefully handle memory or pool allocation failures after
	  beginning to handle a request from the ring.

	* Merge contiguous requests to avoid the "64K turns into 44K + 20K
	  and doubles the transactions per second at the disk" problem
	  caused by the 11-page limit caused by the structure of Xen
	  ring entries.  This causes a very slight performance decrease
	  for sequential 64K I/O if the disk is not already saturated with
	  requests (about 1%) but halves the transactions per second we
	  hit the disk with -- or better.  It even compensates for bizarre
	  Linux behaviour like breaking long requests up into 5.5K pieces.

	* Probably some stuff I forgot to mention.

Disk throughput (though not latency) is now much, much closer to the
"raw hardware" case than it was before.
2005-07-17 08:23:43 +00:00
yamt
1eb847c433 evtchn_do_event: enable interrupts while calling interrupt handlers. 2005-07-15 09:16:23 +00:00
yamt
cdc5b954fc include cardbus/pcmcia.
XXX 32bit cards don't work due to the way how xen handles
pci configuration space.
2005-07-15 07:56:22 +00:00
yamt
300f70f6e0 handle tx buffer exhaustion. 2005-07-07 12:01:25 +00:00
yamt
73a032cf90 create opt_pcifixup.h to match with the recent i386 change. 2005-06-28 12:01:11 +00:00
dyoung
7a7b273b60 Don't include files.ath any more, it's disappeared. 2005-06-25 23:09:54 +00:00
bouyer
acd358ae3d Use the time provided by the hypervisor instead of our global time variable
for xen_microtime(). This match more closely what is done on a real i386
(where we read the RTC), and seems to fix gettimeofday() sometime going
backward by several seconds for me.
2005-06-25 18:44:59 +00:00
dyoung
9063402978 Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD.  Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]).  Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
2005-06-22 06:14:51 +00:00
chs
b36d2dee68 copy the athhal glue from Makefile.i386. 2005-06-19 20:28:14 +00:00
chs
187b985918 add ath stuff. 2005-06-19 20:22:26 +00:00
bouyer
15ce68ccd1 Allow compiling a domain0 kernel with vga but without pckbc, and add
console support for USB keyboard. Problem pointed out by Karl Janmar on
port-xen.
2005-06-16 10:58:52 +00:00
bouyer
6b930c6d27 Add support for x86 boot flags:
-s boot single user
-a ask root device
XXX -d is ifdef'd out for now, it cause early panic (no console message).
2005-06-15 22:08:08 +00:00
bouyer
48c16dfe5f xen_shm_size isn't patchable because _xen_shm_vaddr2ma[] is static, so
remove comment saying it is. Pointed out by Jed Davis.
2005-06-12 14:59:48 +00:00
sjg
aa7b975acd Sometimes .BEGIN target is not wanted - eg in sub-make's. 2005-06-07 18:11:34 +00:00
yamt
84ebe3241f - xen_network_handler: fix transmit stall. (re)start transmit
after collecting tx buffers.
- some assertions.
2005-06-06 11:51:41 +00:00
yamt
6976dba3a6 fix a typo (NETIF_TX_RING_SIZE <-> NETIF_RX_RING_SIZE) 2005-06-06 11:51:02 +00:00
yamt
5c8133c87b privcmd_ioctl: remove unnecessary variable shadowing. 2005-06-01 12:56:02 +00:00
yamt
e76114f7e0 appease -Wcast-qual. 2005-06-01 12:05:28 +00:00
yamt
24ca3e95ec sync with i386. (avoid shadowing) 2005-05-31 13:53:15 +00:00
yamt
80d547c255 remove local prototypes of printk. 2005-05-31 12:44:29 +00:00
yamt
457b7ee79b always provide prototype of printk for now. because:
- currently its implementation is always compiled in.
	- there're users which don't honor XENDEBUG.
2005-05-31 12:42:58 +00:00
yamt
bcc5a2379e avoid variable shadowing. 2005-05-31 12:36:56 +00:00
yamt
9a13650e12 constify. 2005-05-31 11:57:13 +00:00
yamt
3a00578853 x86_variable_test_bit: don't remove const qualifier unnecessarily. 2005-05-31 04:34:53 +00:00
christos
f6b4c20f18 s/GENASSYM/GENASSYM_CONF/ so we can use "GENASSYM" as the program name. 2005-05-31 04:03:08 +00:00
chs
b0a8a83e7b remove vestigal {,e}intr{names,cnt} symbols now that vmstat doesn't need them. 2005-05-31 00:45:02 +00:00
chs
94622623d8 in pmap_enter(), preset the mod/ref bits based on the flags argument.
fixes 25640.
2005-05-29 15:56:59 +00:00
bouyer
45d876eaeb Reset the microtime state in inittodr(), so that the next clock tick will
initialise the microtime state again. it was initialised at the first
clock tick before time of day was set. Should fix port-xen/29846.
Also, try harder to call microset() once a second; the clock interrupt handler
can be called more often than HZ in some case.
2005-05-27 22:02:25 +00:00