iPXE
Macros | Functions | Variables
xengrant.h File Reference

Xen grant tables. More...

#include <stdint.h>
#include <stdlib.h>
#include <ipxe/io.h>
#include <ipxe/xen.h>
#include <xen/grant_table.h>

Go to the source code of this file.

Macros

#define XENGRANT_FAIL_RATE   0
 Induced failure rate (for testing) More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
 FILE_SECBOOT (PERMITTED)
 
static __attribute__ ((always_inline)) int xengrant_query_size(struct xen_hypervisor *xen
 Query grant table size. More...
 
 return (container_of(&v1->flags, struct grant_entry_header, flags))
 
static void xengrant_zero (struct xen_hypervisor *xen, struct grant_entry_header *hdr)
 Zero grant table entry. More...
 
 assert ((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
 
 writew (0, &hdr->flags)
 
 writew (DOMID_SELF, &hdr->domid)
 
 if ((XENGRANT_FAIL_RATE > 0) &&(random() % XENGRANT_FAIL_RATE)==0)
 
 if (sizeof(physaddr_t)==sizeof(uint64_t))
 
 wmb ()
 
 writew ((GTF_permit_access|subflags), &hdr->flags)
 
int xengrant_init (struct xen_hypervisor *xen)
 Initialise grant table. More...
 
int xengrant_alloc (struct xen_hypervisor *xen, grant_ref_t *refs, unsigned int count)
 Allocate grant references. More...
 
void xengrant_free (struct xen_hypervisor *xen, grant_ref_t *refs, unsigned int count)
 Free grant references. More...
 

Variables

static struct gnttab_query_sizesize
 
static struct gnttab_set_version * version
 
static grant_ref_t ref
 
 v1 = &xen->grant.table[ ref << xen->grant.shift ]
 
static grant_ref_t domid_t domid
 
static grant_ref_t domid_t unsigned int subflags
 
static grant_ref_t domid_t unsigned int physaddr_t addr
 
union grant_entry_v2 * v2 = xengrant_v2 ( hdr )
 
unsigned long frame = ( addr / PAGE_SIZE )
 
 else
 
 return
 

Detailed Description

Xen grant tables.

Definition in file xengrant.h.

Macro Definition Documentation

◆ XENGRANT_FAIL_RATE

#define XENGRANT_FAIL_RATE   0

Induced failure rate (for testing)

Definition at line 20 of file xengrant.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED  )

◆ __attribute__()

static __attribute__ ( (always_inline)  )
inlinestatic

Query grant table size.

Permit access to a page.

Invalidate access to a page.

Get version 2 grant table entry.

Get version 1 grant table entry.

Get grant table entry header.

Get number of grant table entries.

Get grant table version.

Set grant table version.

Parameters
xenXen hypervisor
sizeTable size
Return values
xenrcXen status code
Parameters
xenXen hypervisor
versionVersion
Return values
xenrcXen status code
Parameters
xenXen hypervisor
Return values
entriesNumber of grant table entries
Parameters
xenXen hypervisor
refGrant reference
Return values
hdrGrant table entry header
Parameters
hdrGrant table entry header
Return values
v1Version 1 grant table entry
Parameters
hdrGrant table entry header
Return values
v2Version 2 grant table entry
Parameters
xenXen hypervisor
refGrant reference
xenXen hypervisor
refGrant reference
domidDomain ID
subflagsAdditional flags
addrPhysical address within page
Return values
rcReturn status code

Definition at line 76 of file xengrant.h.

77  {
78 
79  return ( ( xen->grant.len / sizeof ( xen->grant.table[0] ) )
80  >> xen->grant.shift );
81 }

References xen_hypervisor::grant, xen_grant::len, xen_grant::shift, xen_grant::table, and xen_device::xen.

◆ return()

return ( container_of &->,,  flags)

◆ xengrant_zero()

static void xengrant_zero ( struct xen_hypervisor xen,
struct grant_entry_header *  hdr 
)
inlinestatic

Zero grant table entry.

Parameters
xenXen hypervisor
hdrGrant table entry header

Definition at line 128 of file xengrant.h.

129  {
130  uint32_t *dword = ( ( uint32_t * ) hdr );
131  unsigned int i = ( ( sizeof ( xen->grant.table[0] ) / sizeof ( *dword ))
132  << xen->grant.shift );
133 
134  while ( i-- )
135  writel ( 0, dword++ );
136 }
struct golan_inbox_hdr hdr
Message header.
Definition: CIB_PRM.h:28
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
struct grant_entry_v1 * table
Grant table entries.
Definition: xen.h:31
unsigned int uint32_t
Definition: stdint.h:12
unsigned int shift
Entry size shift (for later version tables)
Definition: xen.h:35
struct xen_grant grant
Grant table.
Definition: xen.h:57
unsigned long int dword
Definition: smc9000.h:40

References xen_hypervisor::grant, hdr, xen_grant::shift, xen_grant::table, and writel().

Referenced by xengrant_alloc(), and xengrant_free().

◆ assert()

assert ( (readw(&hdr->flags) &(GTF_reading|GTF_writing))  = =0)

Referenced by __attribute__(), _print_label(), a3c90x_internal_ReadEeprom(), acm_transmit(), adaptive_proportion_test_init(), aes_decrypt(), aes_encrypt(), alloc_form(), alloc_iob_raw(), ansicol_set(), ansicol_set_pair(), aoecmd_ata_cmd(), aoecmd_cfg_cmd(), aoecmd_free(), aoecmd_tx(), arbel_alloc_icm(), arbel_close(), arbel_cmd(), arbel_complete(), arbel_map_vpm(), arbel_post_send(), arbel_start_firmware(), asn1_okx(), asn1_parse_cbc(), atadev_read_capacity(), ath5k_handle_rx(), atl_rx_ring_fill(), axge_in_complete(), bigint_add_okx(), bigint_is_geq_okx(), bigint_mod_exp_okx(), bigint_mod_exp_raw(), bigint_mod_invert_raw(), bigint_montgomery_okx(), bigint_montgomery_raw(), bigint_montgomery_relaxed_raw(), bigint_multiply_okx(), bigint_ntoa_raw(), bigint_reduce_okx(), bigint_reduce_raw(), bigint_subtract_okx(), bigint_swap_okx(), bios_ansi_seq(), bios_handle_ed(), bnxt_rx_process(), bzimage_exec(), bzimage_load_initrds(), cachedhcp_record(), cachedhcp_recycle(), cbc_decrypt(), cbc_encrypt(), cbc_setiv(), cbc_xor(), cgem_refill_rx(), chap_init(), chap_respond(), chap_update(), check_blocks(), cipher_cost(), cms_parse_enveloped(), cms_test_exec(), cms_verify_padding(), cms_verify_signer(), com32_exec_loop(), comboot_exec_loop(), concat_args(), cpio_name_len(), deflate_accumulate(), deflate_bin(), deflate_consume(), deflate_inflate(), deflate_init(), delete_character(), der_asn1(), des_decrypt(), des_encrypt(), des_setkey(), dhcp_create_request(), dhcpv6_rx(), dhcpv6_tx(), dma_op_free(), dma_op_ufree(), dma_op_unmap(), dns_xfer_deliver(), drbg_generate(), drbg_instantiate(), drbg_reseed(), drbg_uninstantiate(), dt_remove_node(), dwgpio_probe(), dwmac_create_ring(), dwmac_poll_rx(), dwmac_refill_rx(), eap_rx_md5(), eap_rx_mschapv2_success(), eap_tx_nak(), eapol_eap_rx(), ecam_read(), ecam_write(), ecb_decrypt(), ecb_encrypt(), ecm_probe(), edit_setting(), eepro_transmit(), efab_fill_rx_queue(), efab_receive(), efab_transmit(), efab_transmit_done(), efi_bofm_start(), efi_bofm_stop(), efi_cacert_shutdown(), efi_close_by_child(), efi_close_by_driver(), efi_close_unsafe(), efi_driver_stop(), efi_file_install(), efi_file_path_claim(), efi_file_path_install(), efi_file_read(), efi_handle_ed(), efi_image_exec(), efi_install_table(), efi_local_open_path(), efi_local_step(), efi_netdev_path(), efi_open_by_child_untyped(), efi_open_by_driver_untyped(), efi_open_unsafe_untyped(), efi_open_untyped(), efi_pxe_udp_deliver(), efi_snp_add_claim(), efi_snp_set_mode(), efi_urealloc(), efi_usb_close(), efi_usb_free_all(), efi_usb_path(), efi_usb_probe(), efi_usb_remove(), efi_usb_sync_transfer(), efi_vlan_find(), efidev_free(), efifb_draw(), efipci_dma_map(), efipci_stop(), efirng_get_noise(), efisig_find(), efx_hunt_alloc_special_buffer(), efx_hunt_receive(), efx_hunt_rxq_fill(), efx_hunt_transmit(), efx_hunt_transmit_done(), ehci_bus_close(), ehci_bus_open(), ehci_bus_poll(), ehci_dequeue(), ehci_device_address(), ehci_endpoint_capabilities(), ehci_endpoint_message(), ehci_endpoint_reset(), ehci_enqueue(), ehci_remove(), ehci_ring_fill(), ehci_ring_free(), ena_create_sq(), ena_poll_rx(), ena_poll_tx(), ena_refill_rx(), ena_transmit(), entropy_enable(), entropy_enable_and_test(), eoib_transmit(), exanic_expired(), exanic_i2c_read_bit(), exanic_i2c_write_bit(), exanic_probe_port(), expand_tokens(), falcon_alloc_special_buffer(), falcon_mdio_read(), falcon_mdio_write(), falcon_spi_rw(), fbcon_handle_ed(), fbcon_init(), fbcon_scroll(), fc_els_free(), fc_els_step(), fc_peer_close(), fc_peer_decrement(), fc_peer_examine(), fc_peer_login(), fc_ulp_attach(), fc_ulp_close(), fc_ulp_login(), fc_xchg_free(), fcoe_expired(), fcpcmd_recv_rddata(), fcpcmd_send_cmnd(), fcpcmd_send_wrdata(), fcpdev_identify_device(), fcpdev_scsi_command(), fdt_child(), fdt_describe(), fdt_insert(), fdt_insert_nop(), fdt_nop(), fdt_phandle(), fdt_property(), fdt_set(), fdt_urealloc(), fdtmem_len(), fdtmem_register(), fdtmem_relocate(), fetch_setting_alloc(), fetchf_setting(), fetchf_setting_copy(), fetchn_setting(), find_strings_terminator(), flexboot_nodnic_complete(), flexboot_nodnic_post_send(), format_busdevfn_setting(), free_image(), free_iob(), free_netdev(), free_tls(), free_tls_session(), free_usb(), free_usb_bus(), free_usb_hub(), gcm_multiply_x_8(), gcm_setiv(), gdbserial_recv(), gdbudp_ensure_netdev_open(), generic_settings_clear(), get_entropy_input_tmp(), golan_complete(), golan_provide_pages(), guestinfo_fetch_type(), guestrpc_command(), gve_alloc_qpl(), gve_alloc_queue(), gve_create_queue(), gve_offset(), gve_poll_rx(), gve_poll_tx(), gve_probe(), gve_refill_rx(), gve_transmit(), gzip_extract(), hash_df(), heap_alloc_block(), heap_free_block(), heap_populate(), heap_realloc(), hermon_close(), hermon_cmd(), hermon_complete(), hermon_map_icm(), hermon_map_vpm(), hermon_mod_stat_cfg(), hermon_post_send(), hermon_set_port_type(), hermon_start_firmware(), history_append(), history_cleanup(), history_free(), hmac_drbg_generate(), hmac_drbg_instantiate(), hmac_drbg_reseed(), hmac_drbg_update(), hmac_drbg_update_key(), hmac_drbg_update_value(), http_block_read(), http_conn_close(), http_connect(), http_format_basic_auth(), http_format_digest_auth(), http_format_ntlm_auth(), http_init_transfer_chunked(), http_open_uri(), http_parse_headers(), http_rx_chunk_data(), http_transfer_complete(), http_tx_request(), hub_remove(), hunt_mcdi_copyin(), hv_post_message(), hv_wait_for_message(), hvm_ioremap(), ib_destroy_cq(), ib_destroy_qp(), ib_mcast_attach(), ib_mcast_detach(), ib_mcast_join(), ib_mcast_leave(), ib_mi_send(), ib_open(), ib_pull(), ibft_fill_target_chap(), ibft_fill_target_reverse_chap(), ibft_install(), icert_certs(), icert_encode(), icm_align(), icplus_read_eeprom(), icplus_refill_rx(), image_asn1(), image_exec(), image_replace(), imux_tx(), imux_tx_tcp(), init_i2c_bit_basher(), init_spi_bit_basher(), initrd_load(), initrd_load_all(), initrd_swap(), int13_device_path_info(), int13_guess_geometry(), int22(), intel_read_eeprom(), intel_refill_rx(), intelvf_mbox_msg(), intelxl_admin_command(), intelxl_refill_rx(), iob_map_rx(), iob_pad(), iob_pull(), iob_split(), ioremap_pages(), iounmap_pages(), ipair_expired(), ipair_window_changed(), ipv4_route_okx(), ipv6_add_miniroute(), iscsi_build_login_request_strings(), iscsi_fetch_settings(), iscsi_open_connection(), iscsi_rx_buffered_data(), iscsi_rx_data_in(), iscsi_scsi_done(), iscsi_socket_deliver(), iscsi_start_command(), iscsi_start_login(), iscsi_start_tx(), iscsi_tx_data_out(), iscsi_tx_step(), jump_scroll(), jump_scroll_key(), jump_scroll_move(), kill_eol(), kill_sol(), kill_word(), last_opened_ibdev(), last_opened_netdev(), layout_form(), linda_complete_recv(), linda_complete_send(), linda_ib_epb_mod_reg(), linda_ib_epb_ram_xfer(), linda_post_recv(), linda_post_send(), line_buffer(), lkrn_exec(), lldp_probe(), longjmp_okx(), main_loop(), malloc_phys_offset(), md4_digest(), md4_final(), md5_digest(), md5_final(), memcpy_test_speed(), memmap_update(), menu_loop(), mnpnet_event(), mschapv2_challenge_response(), multiboot_load_raw(), myson_refill_rx(), natsemi_refill_rx(), nbi_process_segments(), ncm_probe(), ndp_register_settings(), neighbour_free(), net80211_change_channel(), net80211_mgmt_dequeue(), net80211_prepare_assoc(), net80211_prepare_probe(), net80211_probe_start(), net80211_set_rate_idx(), netdev_fetch_bustype(), netdev_priv_offset(), netdev_tx_flush(), netfront_create_ring(), netfront_open(), netfront_pull(), netfront_push(), netvsc_create_ring(), netvsc_destroy_ring(), netvsc_transmit(), nii_get_init_info(), numerate_int_setting(), nvs_read(), nvs_write(), ocsp_check(), ocsp_validate(), parse_fc_port(), parse_fc_port_id(), parse_gdb_transport(), parse_integer(), parse_netdev(), parse_netdev_configurator(), parse_setting(), parse_settings(), parse_string(), parse_uuid(), pci_msix_map(), pci_vpd_resize(), peerblk_decrypt(), peerblk_dequeue(), peerblk_enqueue(), peerblk_expired(), peerblk_parse_block(), peerblk_parse_header(), peerblk_reset(), peerdisc_destroy(), peerdisc_open(), peerdist_discovery_reply_values(), peerdist_info(), peerdist_info_block(), peerdist_info_hash_ntoa(), peerdist_info_segment(), peerdist_info_segment_hash(), peerdist_info_v1(), peerdist_info_v1_block(), peerdist_info_v1_block_offset(), peerdist_info_v1_segment(), peerdist_info_v2(), peerdist_info_v2_block(), peerdist_info_v2_segment(), peermux_block_deliver(), pem_asn1(), pem_marker(), phantom_clp_cmd(), phantom_crb_access_128m(), phantom_crb_access_2m(), phantom_crb_access_32m(), phantom_dmesg(), phantom_fetch_setting(), phantom_poll(), phantom_probe(), phantom_refill_rx_ring(), phantom_store_setting(), phantom_transmit(), ping_rx(), pit8254_speaker_delay(), pixbuf_okx(), png_interlace(), png_pixels(), png_pixels_pass(), png_unfilter(), png_unfilter_pass(), pnm_type(), pool_add(), pool_expired(), profile_update(), pxe_fake_cached_info(), pxe_menu_boot(), pxe_netdev_close(), pxe_netdev_open(), pxe_udp_deliver(), pxenv_udp_read(), pxenv_undi_get_information(), qib7322_ahb_mod_reg(), qib7322_complete_recv(), qib7322_complete_send(), qib7322_post_recv(), qib7322_post_send(), qib7322_probe(), rdc_refill_rx(), read(), readline_history(), realtek_refill_rx(), register_image(), register_settings(), register_usb(), register_usb_bus(), reparse_options(), repetition_count_test_init(), rfc_tcpip_chksum(), rndis_tx_defer(), route_ipv4_print(), rsa_encode_digest(), rtc_unhook_isr(), run_tests(), sandev_command(), sandev_command_read_capacity(), sandev_command_rw(), sandev_free(), sandev_reopen(), save_setting(), sdi_exec(), sha1_digest(), sha1_final(), sha256_digest(), sha256_final(), sha512_digest(), sha512_final(), show_menu(), shuffle(), skge_up(), skge_xmit_frame(), sky2_status_intr(), sky2_tx_complete(), slam_parse_multicast_address(), slam_pull_header(), slam_put_value(), smbios_fetch(), smbios_string(), smbios_structure(), smbios_version(), spi_bit_rw(), srp_open(), srpcmd_free(), startup_test_init(), storef_setting(), storen_setting(), tcp_close(), tcp_expired(), tcp_rx_opts(), tcp_rx_seq(), tcp_wait_expired(), tcp_xmit_sack(), tcpip_random_okx(), test_ok(), tg3_rx_complete(), threewire_read(), threewire_write(), timer_expired(), tls_cipherstream_deliver(), tls_generate_keys(), tls_new_ciphertext(), tls_new_record(), tls_newdata_process_data(), tls_newdata_process_header(), tls_restart(), tls_send_record(), tls_set_cipher(), tls_tx_step(), tls_validator_done(), tls_verify_dh_params(), txnic_complete_sqe(), txnic_lmac_probe(), txnic_lmac_probe_all(), txnic_lmac_remove(), txnic_lmac_remove_all(), txnic_refill_rq(), ucode_exec(), ucode_status(), ucode_update_all(), uhci_bus_close(), uhci_bus_open(), uhci_dequeue(), uhci_device_address(), uhci_endpoint_message(), uhci_endpoint_poll(), uhci_endpoint_stream(), uhci_enqueue(), uhci_remove(), uhci_restart(), uhci_ring_fill(), uhci_ring_free(), uheap_find(), uheap_resize(), undinet_call(), undinet_hook_isr(), undinet_poll(), undinet_probe(), undinet_unhook_isr(), unregister_sandev(), unregister_usb(), unregister_usb_bus(), usb_attached(), usb_complete_err(), usb_control(), usb_deconfigure(), usb_describe(), usb_endpoint_close(), usb_endpoint_reset(), usb_flush(), usb_free_address(), usb_hotplug(), usb_message(), usb_prefill(), usb_probe_all(), usb_refill_limit(), usb_remove_all(), usbblk_in_complete(), usbblk_in_data(), usbblk_in_refill(), usbblk_in_status(), usbblk_open(), usbblk_out_command(), usbblk_out_complete(), usbblk_out_data(), usbblk_out_refill(), usbblk_start(), usbio_close(), usbio_endpoint_message(), usbio_interfaces(), usbio_interrupt_callback(), usbio_interrupt_poll(), usbio_open(), usbkbd_consume(), usbkbd_fill(), utf8_accumulate(), validator_append(), validator_start_ocsp(), validator_step(), validator_xfer_close(), vmbus_open(), vmbus_poll(), vmbus_probe(), vmbus_remove_channels(), vmbus_send(), vmbus_send_cancellation(), vmbus_send_completion(), vmbus_send_control(), vmbus_send_data(), vmbus_xfer_page_iobufs(), vmxnet3_refill_rx(), vmxnet3_transmit(), vpm_ioread16(), vpm_ioread32(), vpm_ioread8(), vpm_iowrite16(), vpm_iowrite32(), vpm_iowrite8(), vxge_hw_device_terminate(), weierstrass_add_ladder(), weierstrass_add_raw(), weierstrass_exec(), write_cmd(), x25519_invert(), x509_check_signature(), x509_found(), x509_free_chain(), x509_set_valid(), x509_test_exec(), xcm_free(), xengrant_alloc(), xengrant_free(), xenstore_request(), xferbuf_void_realloc(), xhci_address_device_input(), xhci_bus_close(), xhci_command_free(), xhci_complete(), xhci_dcbaa_free(), xhci_dequeue(), xhci_device_open(), xhci_endpoint_message(), xhci_endpoint_open(), xhci_enqueue(), xhci_enqueue_multi(), xhci_fail(), xhci_init(), xhci_port_status(), xhci_ring_alloc(), xhci_ring_free(), xhci_ring_remaining(), xhci_scratchpad_alloc(), xhci_scratchpad_free(), xhci_transfer(), and xsigo_free().

◆ writew() [1/3]

writew ( ,
&hdr->  flags 
)

◆ writew() [2/3]

writew ( DOMID_SELF  ,
&hdr->  domid 
)

◆ if() [1/2]

if ( (XENGRANT_FAIL_RATE > 0) &&(random() % XENGRANT_FAIL_RATE = = 0)

Definition at line 183 of file xengrant.h.

184  {
185  return -EAGAIN;
186  }
#define EAGAIN
Resource temporarily unavailable.
Definition: errno.h:319

References EAGAIN.

◆ if() [2/2]

if ( sizeof(physaddr_t = = sizeof ( uint64_t ))

Definition at line 194 of file xengrant.h.

194  {
195 
196  /* 64-bit system */
197  if ( xen->grant.shift ) {
198  /* Version 2 table: no possible failure */
199  writeq ( frame, &v2->full_page.frame );
200  } else {
201  /* Version 1 table: may fail if address above 16TB */
202  if ( frame > 0xffffffffUL )
203  return -ERANGE;
204  writel ( frame, &v1->frame );
205  }
206 
207  } else {
v1
Definition: xengrant.h:94
unsigned long frame
Definition: xengrant.h:180
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define ERANGE
Result too large.
Definition: errno.h:640
union grant_entry_v2 * v2
Definition: xengrant.h:179
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.

References ERANGE, frame, xen_hypervisor::grant, xen_grant::shift, v1, v2, writel(), and writeq().

◆ wmb()

wmb ( )

Referenced by __vxge_hw_kdfc_swapper_set(), __vxge_hw_legacy_swapper_set(), __vxge_hw_non_offload_db_post(), __vxge_hw_pio_mem_write64(), __vxge_hw_read_rts_ds(), __vxge_hw_vpath_kdfc_configure(), __vxge_hw_vpath_pci_read(), __vxge_hw_vpath_swapper_set(), amd8111e_init_rx_ring(), amd8111e_poll(), amd8111e_transmit(), atl1e_read_phy_reg(), atl1e_reset_hw(), atl1e_tx_queue(), atl1e_write_phy_reg(), atl_rx_ring_fill(), atl_transmit(), b44_transmit(), bnx2_poll(), bnx2_transmit(), cgem_transmit(), clear_b0_fpga_memories(), dwmac_create_ring(), dwmac_refill_rx(), dwmac_transmit(), ehci_async_schedule(), ehci_endpoint_reset(), ehci_enqueue(), ehci_periodic_schedule(), ena_admin(), ena_destroy_admin(), ena_destroy_async(), ena_refill_rx(), ena_transmit(), exanic_close(), exanic_open(), exanic_transmit(), falcon_read(), falcon_write(), falcon_write_sram(), flexboot_nodnic_arm_cq(), forcedeth_transmit(), golan_cmd_init(), golan_eq_update_ci(), golan_post_recv(), golan_post_send(), gve_admin(), gve_refill_rx(), gve_reset(), gve_transmit(), hunt_mcdi_copyin(), icplus_refill_rx(), icplus_transmit(), intel_refill_rx(), intel_transmit(), intelxl_admin_command(), intelxl_refill_admin(), intelxl_refill_rx(), intelxl_transmit(), is_command_finished(), jme_disable_rx_engine(), jme_disable_tx_engine(), jme_enable_rx_engine(), jme_enable_tx_engine(), jme_fill_tx_desc(), jme_mdio_write(), jme_set_clean_rxdesc(), jme_setup_wakeup_frame(), myri10ge_command(), myri10ge_interrupt_handler(), myri10ge_net_poll(), myri10ge_net_transmit(), myri10ge_post_receive(), myson_refill_rx(), myson_transmit(), natsemi_refill_rx(), natsemi_transmit(), nv_alloc_rx(), pci_push(), pcnet32_refill_rx_ring(), pcnet32_setup_init_block(), pcnet32_transmit(), phantom_poll(), phantom_post_cds(), phantom_post_rds(), rdc_refill_rx(), rdc_transmit(), realtek_refill_rx(), realtek_transmit(), rhine_refill_rx(), rhine_transmit(), send_command(), shomron_tx_uar_send_db(), sis190_give_to_asic(), sis190_make_unusable_by_asic(), sis190_transmit(), skge_poll(), skge_rx_reuse(), skge_rx_setup(), skge_up(), skge_xmit_frame(), sky2_put_idx(), sky2_rx_stop(), txnic_refill_rq(), txnic_send(), uhci_async_schedule(), uhci_describe(), uhci_endpoint_poll(), uhci_enqueue(), uhci_periodic_schedule(), uhci_restart(), velocity_refill_rx(), velocity_transmit(), vmbus_send(), vmxnet3_refill_rx(), vmxnet3_transmit(), vring_add_buf(), vring_detach(), vring_get_buf(), vring_kick(), vring_more_used(), vxge_hw_device_hw_info_get(), vxge_hw_set_fw_api(), vxge_hw_vpath_doorbell_rx(), vxge_open(), xenstore_recv(), xenstore_send(), xhci_doorbell(), and xhci_enqueue().

◆ writew() [3/3]

writew ( (GTF_permit_access|subflags ,
&hdr->  flags 
)

◆ xengrant_init()

int xengrant_init ( struct xen_hypervisor xen)

Initialise grant table.

Parameters
xenXen hypervisor
Return values
rcReturn status code

Definition at line 71 of file xengrant.c.

71  {
72  struct gnttab_query_size size;
73  struct gnttab_set_version set_version;
74  struct gnttab_get_version get_version;
75  struct grant_entry_v1 *v1;
76  union grant_entry_v2 *v2;
77  unsigned int version;
78  int xenrc;
79  int rc;
80 
81  /* Get grant table size */
82  size.dom = DOMID_SELF;
83  if ( ( xenrc = xengrant_query_size ( xen, &size ) ) != 0 ) {
84  rc = -EXEN ( xenrc );
85  DBGC ( xen, "XENGRANT could not get table size: %s\n",
86  strerror ( rc ) );
87  return rc;
88  }
89  xen->grant.len = ( size.nr_frames * PAGE_SIZE );
90 
91  /* Set grant table version, if applicable */
92  set_version.version = XENGRANT_TRY_VERSION;
93  if ( ( xenrc = xengrant_set_version ( xen, &set_version ) ) != 0 ) {
94  rc = -EXEN ( xenrc );
95  DBGC ( xen, "XENGRANT could not set version %d: %s\n",
97  /* Continue; use whatever version is current */
98  }
99 
100  /* Get grant table version */
101  get_version.dom = DOMID_SELF;
102  get_version.pad = 0;
103  if ( ( xenrc = xengrant_get_version ( xen, &get_version ) ) == 0 ) {
104  version = get_version.version;
105  switch ( version ) {
106 
107  case 0:
108  /* Version not yet specified: will be version 1 */
109  version = 1;
110  break;
111 
112  case 1 :
113  /* Version 1 table: nothing special to do */
114  break;
115 
116  case 2:
117  /* Version 2 table: configure shift appropriately */
118  xen->grant.shift = ( fls ( sizeof ( *v2 ) /
119  sizeof ( *v1 ) ) - 1 );
120  break;
121 
122  default:
123  /* Unsupported version */
124  DBGC ( xen, "XENGRANT detected unsupported version "
125  "%d\n", version );
126  return -ENOTSUP;
127 
128  }
129  } else {
130  rc = -EXEN ( xenrc );
131  DBGC ( xen, "XENGRANT could not get version (assuming v1): "
132  "%s\n", strerror ( rc ) );
133  version = 1;
134  }
135 
136  DBGC ( xen, "XENGRANT using v%d table with %d entries\n",
137  version, xengrant_entries ( xen ) );
138  return 0;
139 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint16_t size
Buffer size.
Definition: dwmac.h:14
#define DBGC(...)
Definition: compiler.h:505
v1
Definition: xengrant.h:94
#define PAGE_SIZE
Page size.
Definition: io.h:28
#define ENOTSUP
Operation not supported.
Definition: errno.h:590
#define EXEN(xenrc)
Convert a Xen status code to an iPXE status code.
Definition: xen.h:87
u32 version
Driver version.
Definition: ath9k_hw.c:1985
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
Definition: grant_table.h:118
union grant_entry_v2 * v2
Definition: xengrant.h:179
#define XENGRANT_TRY_VERSION
Grant table version to try setting.
Definition: xengrant.c:63
unsigned int shift
Entry size shift (for later version tables)
Definition: xen.h:35
struct xen_grant grant
Grant table.
Definition: xen.h:57
#define DOMID_SELF
Definition: xen.h:568
size_t len
Total grant table length.
Definition: xen.h:33
#define fls(x)
Find last (i.e.
Definition: strings.h:167

References DBGC, DOMID_SELF, ENOTSUP, EXEN, fls, xen_hypervisor::grant, xen_grant::len, PAGE_SIZE, rc, xen_grant::shift, size, strerror(), v1, v2, version, and XENGRANT_TRY_VERSION.

Referenced by hvm_map_grant().

◆ xengrant_alloc()

int xengrant_alloc ( struct xen_hypervisor xen,
grant_ref_t refs,
unsigned int  count 
)

Allocate grant references.

Parameters
xenXen hypervisor
refsGrant references to fill in
countNumber of references
Return values
rcReturn status code

Definition at line 149 of file xengrant.c.

150  {
151  struct grant_entry_header *hdr;
152  unsigned int entries = xengrant_entries ( xen );
153  unsigned int mask = ( entries - 1 );
154  unsigned int check = 0;
155  unsigned int avail;
156  unsigned int ref;
157 
158  /* Fail unless we have enough references available */
159  avail = ( entries - xen->grant.used - GNTTAB_NR_RESERVED_ENTRIES );
160  if ( avail < count ) {
161  DBGC ( xen, "XENGRANT cannot allocate %d references (only %d "
162  "of %d available)\n", count, avail, entries );
163  return -ENOBUFS;
164  }
165  DBGC ( xen, "XENGRANT allocating %d references (from %d of %d "
166  "available)\n", count, avail, entries );
167 
168  /* Update number of references used */
169  xen->grant.used += count;
170 
171  /* Find unused references */
172  for ( ref = xen->grant.ref ; count ; ref = ( ( ref + 1 ) & mask ) ) {
173 
174  /* Sanity check */
175  assert ( check++ < entries );
176 
177  /* Skip reserved references */
179  continue;
180 
181  /* Skip in-use references */
182  hdr = xengrant_header ( xen, ref );
183  if ( readw ( &hdr->flags ) & GTF_type_mask )
184  continue;
185  if ( readw ( &hdr->domid ) == DOMID_SELF )
186  continue;
187 
188  /* Zero reference */
189  xengrant_zero ( xen, hdr );
190 
191  /* Mark reference as in-use. We leave the flags as
192  * empty (to avoid creating a valid grant table entry)
193  * and set the domid to DOMID_SELF.
194  */
195  writew ( DOMID_SELF, &hdr->domid );
196  DBGC2 ( xen, "XENGRANT allocated ref %d\n", ref );
197 
198  /* Record reference */
199  refs[--count] = ref;
200  }
201 
202  /* Update cursor */
203  xen->grant.ref = ref;
204 
205  return 0;
206 }
struct golan_inbox_hdr hdr
Message header.
Definition: CIB_PRM.h:28
uint16_t readw(volatile uint16_t *io_addr)
Read 16-bit word from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
#define GNTTAB_NR_RESERVED_ENTRIES
Definition: grant_table.h:136
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static unsigned int count
Number of entries.
Definition: dwmac.h:225
#define GTF_type_mask
Definition: grant_table.h:153
static const char grant_ref_t unsigned int struct io_buffer grant_ref_t * refs
Definition: netfront.h:94
unsigned int ref
Most recently used grant reference.
Definition: xen.h:39
#define ENOBUFS
No buffer space available.
Definition: errno.h:499
#define DBGC2(...)
Definition: compiler.h:522
struct xen_grant grant
Grant table.
Definition: xen.h:57
#define writew
Definition: w89c840.c:159
#define DOMID_SELF
Definition: xen.h:568
static const char grant_ref_t ref
Definition: netfront.h:92
static void xengrant_zero(struct xen_hypervisor *xen, struct grant_entry_header *hdr)
Zero grant table entry.
Definition: xengrant.h:128
unsigned int used
Number of grant table entries in use.
Definition: xen.h:37

References assert(), count, DBGC, DBGC2, DOMID_SELF, ENOBUFS, GNTTAB_NR_RESERVED_ENTRIES, xen_hypervisor::grant, GTF_type_mask, hdr, readw(), xen_grant::ref, ref, refs, xen_grant::used, writew, and xengrant_zero().

Referenced by netfront_probe().

◆ xengrant_free()

void xengrant_free ( struct xen_hypervisor xen,
grant_ref_t refs,
unsigned int  count 
)

Free grant references.

Parameters
xenXen hypervisor
refsGrant references
countNumber of references

Definition at line 215 of file xengrant.c.

216  {
217  struct grant_entry_header *hdr;
218  unsigned int ref;
219  unsigned int i;
220 
221  /* Free references */
222  for ( i = 0 ; i < count ; i++ ) {
223 
224  /* Sanity check */
225  ref = refs[i];
226  assert ( ref < xengrant_entries ( xen ) );
227 
228  /* Zero reference */
229  hdr = xengrant_header ( xen, ref );
230  xengrant_zero ( xen, hdr );
231  DBGC2 ( xen, "XENGRANT freed ref %d\n", ref );
232  }
233 }
struct golan_inbox_hdr hdr
Message header.
Definition: CIB_PRM.h:28
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static unsigned int count
Number of entries.
Definition: dwmac.h:225
static const char grant_ref_t unsigned int struct io_buffer grant_ref_t * refs
Definition: netfront.h:94
#define DBGC2(...)
Definition: compiler.h:522
static const char grant_ref_t ref
Definition: netfront.h:92
static void xengrant_zero(struct xen_hypervisor *xen, struct grant_entry_header *hdr)
Zero grant table entry.
Definition: xengrant.h:128

References assert(), count, DBGC2, hdr, ref, refs, and xengrant_zero().

Referenced by netfront_probe(), and netfront_remove().

Variable Documentation

◆ size

struct gnttab_query_size* size
Initial value:
{
return xen_hypercall_3 ( xen, __HYPERVISOR_grant_table_op,
virt_to_phys ( size ), 1 )
#define __HYPERVISOR_grant_table_op
Definition: xen.h:97
#define GNTTABOP_query_size
Definition: grant_table.h:296
static struct gnttab_query_size * size
Definition: xengrant.h:31

Definition at line 31 of file xengrant.h.

◆ version

struct gnttab_get_version* version
Initial value:
{
return xen_hypercall_3 ( xen, __HYPERVISOR_grant_table_op,
GNTTABOP_set_version,
virt_to_phys ( version ), 1 )
static struct gnttab_set_version * version
Definition: xengrant.h:47
#define __HYPERVISOR_grant_table_op
Definition: xen.h:97

Definition at line 47 of file xengrant.h.

◆ ref

Initial value:

Definition at line 91 of file xengrant.h.

◆ v1

struct grant_entry_v1 * v1 = &xen->grant.table[ ref << xen->grant.shift ]

Definition at line 94 of file xengrant.h.

Referenced by if(), and xengrant_init().

◆ domid

Definition at line 174 of file xengrant.h.

◆ subflags

grant_ref_t domid_t unsigned int subflags

Definition at line 174 of file xengrant.h.

◆ addr

grant_ref_t domid_t unsigned int physaddr_t addr
Initial value:
{
struct grant_entry_header *hdr = xengrant_header ( xen, ref )
struct golan_inbox_hdr hdr
Message header.
Definition: CIB_PRM.h:28
static grant_ref_t ref
Definition: xengrant.h:91

Definition at line 176 of file xengrant.h.

◆ v2

union grant_entry_v2* v2 = xengrant_v2 ( hdr )

Definition at line 179 of file xengrant.h.

Referenced by if(), and xengrant_init().

◆ frame

unsigned long frame = ( addr / PAGE_SIZE )

◆ else

else
Initial value:
{
if ( xen->grant.shift ) {
writel ( frame, &v2->full_page.frame );
} else {
writel ( frame, &v1->frame );
}
}
writew ( domid, &hdr->domid )
struct golan_inbox_hdr hdr
Message header.
Definition: CIB_PRM.h:28
v1
Definition: xengrant.h:94
unsigned long frame
Definition: xengrant.h:180
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static grant_ref_t domid_t domid
Definition: xengrant.h:174
union grant_entry_v2 * v2
Definition: xengrant.h:179
writew(0, &hdr->flags)

Definition at line 207 of file xengrant.h.

◆ return

return

Definition at line 225 of file xengrant.h.